/* ── Counter page two-column layout ── */
.counter-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: 0;
  align-items: start;
  margin-top: 4px;
}

/* ── Main Layout ── */

    /* ── Page Title ── */
    /* ── Editor Panel ── */
    .editor-panel {
      grid-column: 1;
      grid-row: 2;
      padding-right: 40px;
    }

    .textarea-wrapper {
      position: relative;
      border: 1px solid var(--border);
      border-radius: 10px;
      background: var(--card);
      overflow: hidden;
      transition: box-shadow 0.2s ease;
    }

    .textarea-wrapper:focus-within {
      box-shadow: 0 0 0 2px var(--blue);
    }

    .textarea-label {
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: 10px 16px;
      border-bottom: 1px solid var(--border);
      background: var(--bg);
    }

    .textarea-label span {
      font-size: 10px;
      letter-spacing: 0.2em;
      color: var(--ink-light);
      text-transform: uppercase;
    }

    .clear-btn {
      background: none;
      border: none;
      cursor: pointer;
      font-size: 10px;
      color: var(--ink-light);
      letter-spacing: 0.15em;
      padding: 2px 6px;
      transition: color 0.15s;
    }

    .clear-btn:hover { color: var(--blue); }

    textarea {
      width: 100%;
      min-height: 380px;
      padding: 20px;
      font-family: var(--sans);
      font-size: 15px;
      font-weight: 300;
      line-height: 1.9;
      color: var(--ink);
      background: transparent;
      border: none;
      resize: vertical;
      outline: none;
      letter-spacing: 0.03em;
    }

    textarea::placeholder {
      color: var(--ink-xlight);
      font-weight: 300;
    }

    /* ── Stats Sidebar ── */
    .stats-panel {
      grid-column: 2;
      grid-row: 2;
    }

    .stats-header {
      font-size: 10px;
      letter-spacing: 0.25em;
      color: var(--ink-light);
      text-transform: uppercase;
      padding-bottom: 12px;
      border-bottom: 2px solid var(--blue);
      margin-bottom: 20px;
    }

    /* Big feature stat */
    .stat-hero {
      background: var(--blue);
      color: #fff;
      border-radius: 10px;
      padding: 24px 20px;
      margin-bottom: 20px;
      position: relative;
      overflow: hidden;
    }

    .stat-hero::before {
      content: '';
      position: absolute;
      top: -20px;
      right: -20px;
      width: 80px;
      height: 80px;
      border: 1px solid rgba(255,255,255,0.08);
      border-radius: 50%;
    }

    .stat-hero-label {
      font-size: 10px;
      letter-spacing: 0.2em;
      color: rgba(255,255,255,0.5);
      margin-bottom: 8px;
      text-transform: uppercase;
    }

    .stat-hero-value {
      font-size: 52px;
      font-weight: 400;
      letter-spacing: -0.02em;
      line-height: 1;
      color: #FFFFFF;
      transition: all 0.2s ease;
    }

    .stat-hero-sub {
      font-size: 11px;
      color: rgba(255,255,255,0.4);
      margin-top: 6px;
      font-weight: 300;
      letter-spacing: 0.08em;
    }

    /* Grid stats */
    .stats-grid {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 1px;
      background: var(--border);
      border: 1px solid var(--border);
      border-radius: 8px;
      overflow: hidden;
      margin-bottom: 20px;
    }

    .stat-cell {
      background: var(--card);
      padding: 14px 14px 12px;
    }

    .stat-cell-label {
      font-size: 10px;
      color: var(--ink-light);
      letter-spacing: 0.1em;
      margin-bottom: 4px;
      font-weight: 300;
    }

    .stat-cell-value {
      font-size: 22px;
      font-weight: 400;
      color: var(--ink);
      transition: all 0.15s ease;
    }

    /* Reading time block */
    .stat-reading {
      border: 1px solid var(--blue-mid);
      border-radius: 8px;
      padding: 14px 16px;
      background: var(--blue-light);
      display: flex;
      align-items: center;
      gap: 12px;
      margin-bottom: 20px;
    }

    .stat-reading-icon {
      font-size: 18px;
      flex-shrink: 0;
    }

    .stat-reading-text {
      font-size: 12px;
      color: var(--ink-light);
      line-height: 1.5;
      font-weight: 300;
    }

    .stat-reading-time {
      font-size: 15px;
      color: var(--blue);
      font-weight: 400;
    }

    /* Composition bar */
    .composition-block {
      margin-bottom: 20px;
    }

    .composition-title {
      font-size: 10px;
      letter-spacing: 0.2em;
      color: var(--ink-light);
      text-transform: uppercase;
      margin-bottom: 10px;
    }

    .comp-bar {
      height: 6px;
      background: var(--border);
      border-radius: 3px;
      display: flex;
      overflow: hidden;
      margin-bottom: 8px;
    }

    .comp-bar-kanji   { background: var(--ink-mid); border-radius: 3px; transition: width 0.3s ease; }
    .comp-bar-hira    { background: #2563EB; transition: width 0.3s ease; }
    .comp-bar-kata    { background: #9CA3AF; transition: width 0.3s ease; }
    .comp-bar-latin   { background: #D1D5DB; transition: width 0.3s ease; }
    .comp-bar-number  { background: var(--border); transition: width 0.3s ease; }

    .comp-legend {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 4px 8px;
    }

    .comp-item {
      display: flex;
      align-items: center;
      gap: 5px;
      font-size: 10px;
      color: var(--ink-light);
      font-weight: 300;
    }

    .comp-dot {
      width: 6px;
      height: 6px;
      border-radius: 50%;
      flex-shrink: 0;
    }

    .comp-item-count {
      font-size: 10px;
      color: var(--ink);
      margin-left: auto;
    }

    /* Density meter */
    .density-block {
      border-top: 1px solid var(--border);
      padding-top: 16px;
    }

    .density-label {
      font-size: 10px;
      letter-spacing: 0.2em;
      color: var(--ink-light);
      text-transform: uppercase;
      margin-bottom: 8px;
    }

    .density-bar-wrap {
      height: 3px;
      background: var(--border);
      border-radius: 2px;
      position: relative;
    }

    .density-bar-fill {
      height: 100%;
      background: var(--blue);
      border-radius: 2px;
      transition: width 0.4s ease;
      max-width: 100%;
    }

    .density-desc {
      font-size: 10px;
      color: var(--ink-light);
      margin-top: 6px;
      font-weight: 300;
    }

    /* Animation for value changes */
    @keyframes flash {
      0% { opacity: 0.4; }
      100% { opacity: 1; }
    }

    .updated {
      animation: flash 0.3s ease;
    }

    /* ── Footer ── */

    /* Responsive */
    /* ── Readable text tool adjustments ── */
    .editor-panel {
      padding-right: 28px;
    }
    .textarea-wrapper {
      border-radius: 0;
      background: #FFFFFF;
    }
    textarea {
      min-height: 480px;
      padding: 24px 26px;
      font-size: 16px;
      line-height: 2;
      font-weight: 400;
      letter-spacing: 0.02em;
      background: #FFFFFF;
    }
    .stats-panel {
      position: sticky;
      top: 18px;
    }
    .stat-hero {
      border-radius: 0;
    }
    .stats-grid {
      border-radius: 0;
    }
    .stat-reading {
      border-radius: 0;
    }
    @media (max-width: 1000px) {
      .editor-panel {
        padding-right: 0;
      }
      .stats-panel {
        position: static;
      }
      textarea {
        min-height: 360px;
        font-size: 15px;
      }
    }

    /* ── Text readability fix ── */
    textarea {
      font-weight: 400;
      letter-spacing: 0;
      line-height: 1.85;
      color: var(--ink);
    }
    textarea::placeholder {
      color: var(--ink-light);
      font-weight: 400;
      letter-spacing: 0;
    }
    .textarea-label span,
    .clear-btn,
    .stat-cell-label,
    .stat-reading-text,
    .legend-label {
      font-weight: 400;
    }

.counter-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: 0;
  align-items: start;
}

@media (max-width: 1000px) {
  .counter-layout {
    grid-template-columns: 1fr;
    gap: 24px;
  }
  .editor-panel {
    grid-column: 1;
    grid-row: 1;
    padding-right: 0;
  }
  .stats-panel {
    grid-column: 1;
    grid-row: 2;
    position: static;
  }
}
