:root {
        color-scheme: light;
        --bg: #f5f7f8;
        --surface: #ffffff;
        --surface-soft: #f0f4f5;
        --line: #d9e1e4;
        --line-strong: #b9c8ce;
        --text: #142126;
        --muted: #64747c;
        --accent: #24505a;
        --accent-strong: #173941;
        --accent-soft: #e3f0f2;
        --success: #1e6b50;
        --danger: #a33b3b;
        --warning: #8a5a14;
        --shadow: 0 16px 44px rgba(20, 33, 38, 0.08);
        --radius: 8px;
        --mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
        --sans: "Inter", "Avenir Next", "Helvetica Neue", "PingFang SC", "Noto Sans SC", sans-serif;
      }

      * {
        box-sizing: border-box;
      }

      html,
      body {
        min-height: 100%;
        margin: 0;
      }

      body {
        font-family: var(--sans);
        color: var(--text);
        background:
          linear-gradient(180deg, rgba(36, 80, 90, 0.06), transparent 240px),
          var(--bg);
      }

      button,
      input,
      textarea {
        font: inherit;
      }

      button {
        border: 0;
      }

      .app {
        width: min(1280px, calc(100vw - 32px));
        margin: 0 auto;
        padding: 22px 0 28px;
      }

      .topbar {
        display: flex;
        align-items: flex-end;
        justify-content: space-between;
        gap: 18px;
        margin-bottom: 16px;
      }

      .title-block {
        min-width: 0;
      }

      .eyebrow {
        margin: 0 0 7px;
        color: var(--accent);
        font-size: 0.78rem;
        font-weight: 800;
        letter-spacing: 0.14em;
        text-transform: uppercase;
      }

      h1 {
        margin: 0;
        font-size: clamp(1.65rem, 3vw, 2.7rem);
        line-height: 1.08;
        letter-spacing: 0;
      }

      .title-targets {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
        margin-top: 12px;
      }

      .title-targets span {
        display: inline-flex;
        align-items: center;
        min-height: 30px;
        padding: 5px 10px;
        border: 1px solid var(--line);
        border-radius: var(--radius);
        background: var(--surface);
        color: var(--accent);
        font-size: 0.86rem;
        font-weight: 800;
      }

      .meta-row {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
        justify-content: flex-end;
      }

      .meta-chip {
        display: inline-flex;
        align-items: center;
        min-height: 32px;
        padding: 6px 10px;
        border: 1px solid var(--line);
        border-radius: var(--radius);
        background: var(--surface);
        color: var(--muted);
        font-size: 0.86rem;
        white-space: nowrap;
      }

      .github-link {
        gap: 7px;
        color: var(--text);
        text-decoration: none;
      }

      .github-link:hover {
        border-color: var(--line-strong);
        background: var(--surface-soft);
      }

      .github-link svg {
        width: 18px;
        height: 18px;
        flex: 0 0 auto;
        fill: currentColor;
      }

      .toolbar {
        display: grid;
        grid-template-columns: 1fr auto;
        gap: 12px;
        align-items: center;
        margin-bottom: 12px;
      }

      .segmented {
        display: inline-grid;
        grid-template-columns: repeat(6, minmax(0, 1fr));
        width: min(760px, 100%);
        padding: 4px;
        border: 1px solid var(--line);
        border-radius: var(--radius);
        background: var(--surface);
      }

      .segmented button {
        min-height: 38px;
        min-width: 0;
        padding: 0 8px;
        border-radius: 6px;
        background: transparent;
        color: var(--muted);
        cursor: pointer;
        line-height: 1.15;
        white-space: normal;
        overflow-wrap: anywhere;
      }

      .segmented button[aria-pressed="true"] {
        background: var(--accent);
        color: #fff;
      }

      .actions {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
        justify-content: flex-end;
      }

      .button {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        min-height: 38px;
        padding: 9px 13px;
        border-radius: var(--radius);
        cursor: pointer;
        transition: background 140ms ease, border-color 140ms ease, color 140ms ease;
      }

      .button-primary {
        background: var(--accent);
        color: #fff;
      }

      .button-primary:hover {
        background: var(--accent-strong);
      }

      .button-secondary,
      .button-ghost {
        border: 1px solid var(--line);
        background: var(--surface);
        color: var(--text);
      }

      .button-secondary:hover,
      .button-ghost:hover {
        border-color: var(--line-strong);
        background: var(--surface-soft);
      }

      .button:disabled {
        cursor: not-allowed;
        opacity: 0.55;
      }

      .workspace {
        display: grid;
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
        gap: 12px;
        align-items: stretch;
      }

      .panel {
        min-width: 0;
        border: 1px solid var(--line);
        border-radius: var(--radius);
        background: var(--surface);
        box-shadow: var(--shadow);
      }

      .panel-head {
        display: flex;
        align-items: flex-start;
        justify-content: space-between;
        gap: 12px;
        padding: 14px 16px;
        border-bottom: 1px solid var(--line);
      }

      .panel-head h2 {
        margin: 0;
        font-size: 1rem;
        line-height: 1.35;
      }

      .panel-head p {
        margin: 4px 0 0;
        color: var(--muted);
        font-size: 0.88rem;
        line-height: 1.45;
      }

      .panel-body {
        padding: 14px 16px 16px;
      }

      .session-guide {
        margin: 0 0 12px;
        padding: 13px 14px;
        border: 1px solid rgba(36, 80, 90, 0.34);
        border-left: 5px solid var(--accent);
        border-radius: var(--radius);
        background: #eaf5f7;
        color: var(--text);
        line-height: 1.5;
      }

      .session-guide strong {
        display: block;
        margin-bottom: 4px;
        color: var(--accent-strong);
        font-size: 0.98rem;
      }

      .session-guide p {
        margin: 0;
        color: #33464d;
        font-size: 0.9rem;
      }

      .session-guide a {
        color: var(--accent-strong);
        font-family: var(--mono);
        font-weight: 800;
        overflow-wrap: anywhere;
      }

      .session-guide .session-warning {
        margin-top: 7px;
        color: var(--danger);
        font-weight: 700;
      }

      .discord-card {
        position: relative;
        display: grid;
        grid-template-columns: auto minmax(0, 1fr);
        gap: 12px 14px;
        align-items: start;
        margin-bottom: 12px;
        padding: 14px 14px 52px;
        border: 1px solid rgba(88, 101, 242, 0.28);
        border-radius: var(--radius);
        background: #f3f5ff;
        color: #243064;
        text-decoration: none;
      }

      .discord-card:hover {
        border-color: rgba(88, 101, 242, 0.5);
        background: #eef1ff;
      }

      .discord-icon {
        display: grid;
        width: 44px;
        height: 44px;
        place-items: center;
        border-radius: var(--radius);
        background: #5865f2;
        color: #fff;
      }

      .discord-icon svg {
        width: 27px;
        height: 27px;
        fill: currentColor;
      }

      .discord-copy strong {
        display: block;
        margin-bottom: 4px;
        color: #1f2a62;
        font-size: 0.98rem;
        line-height: 1.35;
      }

      .discord-copy span {
        display: block;
        color: #46517f;
        font-size: 0.88rem;
        line-height: 1.45;
      }

      .discord-action {
        position: absolute;
        right: 14px;
        bottom: 14px;
        min-height: 32px;
        padding: 6px 12px;
        border-radius: 6px;
        background: #5865f2;
        color: #fff;
        font-weight: 800;
        white-space: nowrap;
        box-shadow: 0 8px 18px rgba(88, 101, 242, 0.22);
      }

      .input-actions {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
        justify-content: space-between;
        margin-bottom: 12px;
      }

      .textarea-shell {
        position: relative;
      }

      textarea {
        display: block;
        width: 100%;
        min-height: 430px;
        resize: vertical;
        border: 1px solid var(--line);
        border-radius: var(--radius);
        padding: 12px;
        background: #fbfcfd;
        color: var(--text);
        font-family: var(--mono);
        font-size: 0.84rem;
        line-height: 1.5;
        white-space: pre;
      }

      textarea:focus {
        outline: 2px solid rgba(36, 80, 90, 0.22);
        border-color: var(--accent);
      }

      textarea[readonly] {
        background: #f8fafb;
      }

      .summary {
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 8px;
        margin-bottom: 12px;
      }

      .stat {
        min-height: 72px;
        padding: 10px;
        border: 1px solid var(--line);
        border-radius: var(--radius);
        background: var(--surface-soft);
      }

      .stat-value {
        font-family: var(--mono);
        font-size: 1.22rem;
        font-weight: 800;
      }

      .stat-label {
        margin-top: 4px;
        color: var(--muted);
        font-size: 0.82rem;
      }

      .accounts {
        overflow: auto;
        max-height: 212px;
        margin-bottom: 12px;
        border: 1px solid var(--line);
        border-radius: var(--radius);
      }

      table {
        width: 100%;
        border-collapse: collapse;
        table-layout: fixed;
        font-size: 0.86rem;
      }

      th,
      td {
        padding: 9px 10px;
        border-bottom: 1px solid var(--line);
        text-align: left;
        vertical-align: top;
      }

      th {
        position: sticky;
        top: 0;
        z-index: 1;
        background: var(--surface-soft);
        color: var(--muted);
        font-size: 0.78rem;
        font-weight: 800;
      }

      tr:last-child td {
        border-bottom: 0;
      }

      .col-name {
        width: 23%;
      }

      .col-email {
        width: 31%;
      }

      .col-expiry {
        width: 24%;
      }

      .cell-clip {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
      }

      .empty {
        color: var(--muted);
      }

      .status-line {
        min-height: 22px;
        margin-top: 10px;
        color: var(--muted);
        font-size: 0.88rem;
        line-height: 1.45;
      }

      .status-line.is-ok {
        color: var(--success);
      }

      .status-line.is-error {
        color: var(--danger);
      }

      .issues {
        display: none;
        margin: 0 0 12px;
        padding: 10px 12px;
        border: 1px solid rgba(163, 59, 59, 0.22);
        border-radius: var(--radius);
        background: #fff7f7;
        color: var(--danger);
        font-size: 0.88rem;
        line-height: 1.45;
      }

      .issues.is-visible {
        display: block;
      }

      .notice {
        margin: 0 0 12px;
        padding: 10px 12px;
        border: 1px solid rgba(138, 90, 20, 0.22);
        border-radius: var(--radius);
        background: #fffaf0;
        color: var(--warning);
        font-size: 0.88rem;
        line-height: 1.45;
      }

      .hidden {
        display: none !important;
      }

      @media (max-width: 960px) {
        .topbar,
        .toolbar,
        .workspace {
          grid-template-columns: 1fr;
        }

        .topbar {
          align-items: flex-start;
        }

        .meta-row,
        .actions {
          justify-content: flex-start;
        }

        .workspace {
          display: block;
        }

        .panel + .panel {
          margin-top: 12px;
        }
      }

      @media (max-width: 620px) {
        .app {
          width: min(100vw - 20px, 1280px);
          padding-top: 14px;
        }

        .toolbar {
          display: block;
        }

        .segmented {
          grid-template-columns: repeat(2, minmax(0, 1fr));
          width: 100%;
          margin-bottom: 10px;
        }

        .actions,
        .input-actions {
          display: grid;
          grid-template-columns: 1fr;
        }

        .button {
          width: 100%;
        }

        .summary {
          grid-template-columns: 1fr;
        }

        .discord-card {
          grid-template-columns: auto minmax(0, 1fr);
        }

        .col-expiry,
        .col-type,
        td:nth-child(3),
        td:nth-child(4),
        th:nth-child(3),
        th:nth-child(4) {
          display: none;
        }

        .col-name,
        .col-email {
          width: 50%;
        }

        textarea {
          min-height: 320px;
          font-size: 0.8rem;
        }
      }
