/* Premium Minimalist Aesthetic */
:root {
  --app-bg: #f6f7fb;
  --app-surface: #ffffff;
  --app-surface-soft: #f8f6f1;
  --app-surface-tint: #eef4ff;
  --app-border: #d8e2ee;
  --app-border-strong: #c4d2e4;
  --app-text: #1f2937;
  --app-text-muted: #5f6f86;
  --app-accent: #2e6fd8;
  --app-accent-soft: rgba(46, 111, 216, 0.12);
  --app-shadow: 0 18px 40px rgba(27, 39, 58, 0.08), 0 4px 10px rgba(27, 39, 58, 0.04);
  --app-radius: 14px;
}

.character-word-counter-page {
  line-height: 1.5;
  /* Map ink palette into canonical chrome tokens. */
  --chrome-ink: #1f2937;
  --chrome-ink-muted: #5f6f86;
}

.character-counter-ui {
  position: relative;
}

/* Layout System - Robust Flex */
.tool-ui-container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0;
}

.workbench {
  display: flex;
  flex-wrap: wrap;
  gap: 32px;
  align-items: flex-start;
}

.workbench-main {
  flex: 1 1 600px;
  min-width: 0;
  background:
    linear-gradient(180deg, rgba(248, 246, 241, 0.92) 0%, rgba(255, 255, 255, 0.96) 22%, rgba(255, 255, 255, 1) 100%);
  color: var(--app-text);
  border: 1px solid var(--app-border-strong);
  border-radius: var(--app-radius);
  padding: 24px;
  box-shadow: var(--app-shadow);
  position: relative;
  overflow: hidden;
}

.workbench-main::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 4px;
  background: linear-gradient(90deg, #dbc27b 0%, #8ea8d4 52%, #d9e4f4 100%);
}

.workbench-sidebar {
  flex: 0 0 320px;
  position: sticky;
  top: 2rem;
}

@media (max-width: 960px) {
  .workbench {
    gap: 20px;
  }

  .workbench-sidebar {
    flex: 1 1 100%;
    position: static;
    order: -1;
  }

  .workbench-main {
    flex-basis: 100%;
    padding: 20px;
  }

  .premium-input {
    min-height: 240px;
  }
}

/* Editor Style */
.editor-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 14px;
  gap: 12px;
}

.editor-title-group {
  display: grid;
  gap: 4px;
}

.editor-title-group .label-heading {
  color: var(--app-text);
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.editor-title-group .text-muted {
  margin: 0;
  color: var(--app-text-muted);
  font-size: 0.82rem;
  line-height: 1.45;
}

.pulse-rail {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.pulse-chip {
  padding: 12px 14px;
  border: 1px solid rgba(196, 210, 228, 0.95);
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(238, 244, 255, 0.72), rgba(255, 255, 255, 0.96));
  display: grid;
  gap: 4px;
  min-width: 0;
}

.pulse-chip-status {
  background: linear-gradient(180deg, rgba(248, 246, 241, 0.88), rgba(255, 255, 255, 0.98));
}

.pulse-label {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--app-text-muted);
}

.pulse-value {
  font-size: 0.92rem;
  line-height: 1.3;
  color: var(--app-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.premium-input {
  width: 100%;
  min-height: 420px;
  padding: 1.25rem;
  border: 1px solid rgba(196, 210, 228, 0.9);
  border-radius: var(--app-radius);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.92) 0%, rgba(251, 252, 255, 0.98) 100%);
  font-size: 1.05rem;
  color: var(--app-text);
  line-height: 1.7;
  resize: vertical;
  transition: border-color 0.2s, box-shadow 0.2s;
  box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.04);
}

.premium-input:focus {
  outline: none;
  border-color: var(--app-accent);
  box-shadow: 0 0 0 4px rgba(46, 111, 216, 0.12);
}

/* Metrics Panel */
.metrics-panel {
  background:
    linear-gradient(180deg, rgba(238, 244, 255, 0.74) 0%, rgba(255, 255, 255, 0.97) 42%, rgba(255, 255, 255, 1) 100%);
  color: var(--app-text);
  border: 1px solid var(--app-border-strong);
  border-radius: var(--app-radius);
  padding: 24px;
  box-shadow: var(--app-shadow);
}

.panel-section {
  padding: 16px 0;
}

.panel-kicker {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--app-accent);
  margin-bottom: 8px;
  font-weight: 700;
}

.panel-heading {
  font-size: 1.02rem;
}

.panel-section.divider {
  border-top: 1px solid #f1f5f9;
}

.panel-section.last {
  padding-bottom: 0;
}

/* Main Stats Grid */
.main-stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.stat-box {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(248, 251, 255, 0.92));
  border: 1px solid rgba(196, 210, 228, 0.92);
  padding: 16px;
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.85);
}

.stat-box .stat-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--app-text-muted);
  margin-bottom: 4px;
}

.stat-box .stat-value {
  font-size: 1.7rem;
  font-weight: 700;
  color: var(--app-text);
  line-height: 1.1;
}

/* Secondary Stats */
.stat-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  font-size: 0.9rem;
  color: var(--app-text-muted);
}

.stat-row strong {
  color: var(--app-text);
}

/* Gauge Styles - FIXED CLIPPING */
.gauge-wrapper {
  position: relative;
  width: 160px;
  height: 90px;
  margin: 0 auto;
}

.readability-gauge {
  width: 100%;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.05));
}

.gauge-bg {
  fill: none;
  stroke: rgba(143, 163, 193, 0.26);
  stroke-width: 8;
  stroke-linecap: round;
}

.gauge-path {
  fill: none;
  stroke: var(--app-accent);
  stroke-width: 8;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.8s ease-out, stroke 0.3s ease;
}

.gauge-content {
  position: absolute;
  top: 55%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}

.gauge-value {
  font-size: 1.75rem;
  line-height: 1;
  color: var(--app-text);
}

.gauge-label {
  font-size: 0.7rem;
  color: var(--app-text-muted);
  text-transform: uppercase;
  margin-top: 4px;
  letter-spacing: 0.08em;
}

.analysis-note {
  margin: 10px auto 0;
  max-width: 18rem;
  font-size: 0.83rem;
  color: var(--app-text-muted);
  line-height: 1.4;
}

/* Keywords */
.keyword-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.keyword-tag {
  background: rgba(46, 111, 216, 0.08);
  border: 1px solid rgba(46, 111, 216, 0.14);
  padding: 5px 10px;
  border-radius: 100px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--app-text);
}

/* Time Context */
.time-estimates {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.time-item {
  font-size: 0.85rem;
  color: var(--app-text-muted);
}

.time-item strong {
  color: var(--app-text);
  margin-left: 4px;
}

/* Achievement Toast (Quiet) */
.tool-notes.card {
  margin-top: 20px;
}

.tool-notes .card-title {
  margin-bottom: 8px;
}

.mb-md { margin-bottom: 12px; }
.mb-sm { margin-bottom: 8px; }
.text-center { text-align: center; }
.text-xxs { font-size: 0.78rem; }
.placeholder-text { font-style: italic; color: var(--app-text-muted); font-size: 0.78rem; }

@media (max-width: 720px) {
  .editor-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .pulse-rail {
    grid-template-columns: 1fr;
  }

  .pulse-chip {
    padding: 11px 12px;
  }

  .metrics-panel {
    padding: 20px;
  }

  .main-stats-grid {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: no-preference) {
  .workbench-main,
  .metrics-panel {
    animation: rise-in 360ms ease-out;
  }

  .pulse-chip,
  .stat-box {
    animation: settle-in 420ms ease-out;
  }
}

@keyframes rise-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes settle-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}
