    :root {
      --bg: #f4f1eb;
      --paper: rgba(255, 255, 255, 0.82);
      --ink: #18212b;
      --muted: #5d6872;
      --line: rgba(24, 33, 43, 0.1);
      --line-strong: rgba(24, 33, 43, 0.16);
      --accent: #23425e;
      --success: #24664a;
      --success-soft: #e4f3ea;
      --warning: #9a6a20;
      --warning-soft: #fbf2df;
      --danger: #a14842;
      --shadow: 0 24px 60px rgba(24, 33, 43, 0.08);
      --sans: "Segoe UI", "Segoe UI Variable Text", "SF Pro Text", "Helvetica Neue", Arial, sans-serif;
    }

    html {
      scrollbar-gutter: stable;
      -webkit-text-size-adjust: 100%;
    }

    * { box-sizing: border-box; margin: 0; padding: 0; }
    body {
      font-family: var(--sans);
      background:
        radial-gradient(circle at top left, rgba(255,255,255,0.92), rgba(255,255,255,0) 38%),
        linear-gradient(180deg, #fbfaf7 0%, var(--bg) 100%);
      color: var(--ink);
      min-height: 100vh;
      padding: 24px;
    }
    a { color: inherit; text-decoration: none; }
    button,
    input { font: inherit; }
    button { cursor: pointer; }

    .page {
      max-width: 1180px;
      margin: 0 auto;
    }
    .frame {
      background: var(--paper);
      border: 1px solid rgba(255,255,255,0.7);
      box-shadow: var(--shadow);
      border-radius: 36px;
      backdrop-filter: blur(18px);
      overflow: hidden;
      animation: page-soft-rise 0.45s ease-out both;
    }
    .shell > .panel {
      animation: page-soft-rise 0.42s ease-out both;
      animation-delay: 0.08s;
    }
    @keyframes page-soft-rise {
      from { opacity: 0; transform: translateY(8px); }
      to { opacity: 1; transform: translateY(0); }
    }
    @media (prefers-reduced-motion: reduce) {
      .frame,
      .shell > .panel {
        animation: none;
      }
    }
    .nav {
      display: flex;
      justify-content: space-between;
      align-items: center;
      gap: 16px;
      padding: 22px 26px;
      border-bottom: 1px solid var(--line);
    }
    .brand {
      display: inline-flex;
      align-items: center;
      gap: 12px;
      font-size: 1.2rem;
      font-weight: 700;
      letter-spacing: 0.02em;
    }
    .brand-mark {
      width: 32px;
      height: 32px;
      flex-shrink: 0;
      display: block;
      filter: drop-shadow(0 2px 5px rgba(35, 66, 94, 0.22));
    }
    .nav-actions {
      display: flex;
      gap: 10px;
      flex-wrap: wrap;
    }
    .nav-link,
    .nav-danger,
    .nav-pill,
    .btn,
    .inline-link {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      border-radius: 999px;
      font-size: 0.9rem;
      font-weight: 700;
      transition: transform 0.16s ease, border-color 0.16s ease, background 0.16s ease;
    }
    .nav-link,
    .nav-danger,
    .nav-pill,
    .inline-link {
      padding: 12px 18px;
      border: 1px solid var(--line-strong);
      background: rgba(255,255,255,0.8);
      color: var(--ink);
    }
    .nav-link:hover,
    .nav-danger:hover,
    .btn:hover,
    .inline-link:hover {
      transform: translateY(-1px);
    }
    .nav-danger {
      border-color: rgba(161, 72, 66, 0.18);
      color: var(--danger);
    }
    .nav-pill {
      color: var(--ink);
      cursor: default;
    }
    .nav-pill[aria-current="page"] {
      background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(230, 238, 245, 0.65));
      border-color: rgba(35, 66, 94, 0.34);
      box-shadow:
        0 0 0 1px rgba(35, 66, 94, 0.06),
        0 4px 16px rgba(35, 66, 94, 0.1);
      color: var(--accent);
    }
    a.nav-link.is-disabled {
      pointer-events: none;
      cursor: default;
      opacity: 0.52;
      color: var(--muted);
    }
    a.nav-link.is-disabled:hover {
      transform: none;
    }
    .nav-menu-btn {
      display: none;
      align-items: center;
      justify-content: center;
      width: 44px;
      height: 44px;
      padding: 0;
      border-radius: 999px;
      border: 1px solid var(--line-strong);
      background: #ffffff;
      color: var(--accent);
      cursor: pointer;
      box-shadow: 0 2px 10px rgba(24, 33, 43, 0.05);
      flex-shrink: 0;
      transition: border-color 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
    }
    .nav-menu-btn:hover {
      border-color: rgba(35, 66, 94, 0.28);
      box-shadow: 0 6px 16px rgba(24, 33, 43, 0.08);
    }
    .nav-menu-btn:focus-visible {
      outline: none;
      box-shadow: 0 0 0 3px rgba(35, 66, 94, 0.2);
    }
    .nav-menu-panel {
      display: none;
    }
    .sr-only {
      position: absolute;
      width: 1px;
      height: 1px;
      padding: 0;
      margin: -1px;
      overflow: hidden;
      clip: rect(0, 0, 0, 0);
      white-space: nowrap;
      border: 0;
    }

    .shell {
      padding: 24px;
      display: flex;
      justify-content: center;
    }
    .panel {
      width: min(940px, 100%);
      background:
        linear-gradient(180deg, rgba(255,255,255,0.96), rgba(255,255,255,0.86)),
        linear-gradient(135deg, rgba(230,238,245,0.26), rgba(255,255,255,0));
      border: 1px solid var(--line);
      border-radius: 30px;
      padding: 28px;
    }

    @media (min-width: 861px) and (min-height: 760px) {
      .panel {
        min-height: clamp(480px, calc(100vh - 220px), 560px);
      }
    }
    .key-status {
      display: none;
      align-items: center;
      justify-content: space-between;
      gap: 14px;
      padding: 13px 16px;
      border-radius: 16px;
      border: 1px solid var(--line);
      margin-bottom: 16px;
      background: rgba(255,255,255,0.82);
    }
    .key-status-main {
      display: inline-flex;
      align-items: center;
      min-width: 0;
    }
    .key-status-title {
      font-size: 0.95rem;
      font-weight: 700;
      letter-spacing: -0.01em;
      margin-bottom: 2px;
    }
    .key-status-copy {
      color: var(--muted);
      font-size: 0.84rem;
      line-height: 1.45;
    }
    #statusReturnLink {
      display: none;
    }
    .key-status.set {
      background: linear-gradient(180deg, rgba(228,243,234,0.92), rgba(255,255,255,0.92));
      border-color: rgba(36, 102, 74, 0.26);
    }
    .key-status.set #statusReturnLink {
      display: inline-flex;
    }
    .key-status.replacing {
      background: linear-gradient(180deg, rgba(243, 228, 226, 0.92), rgba(255, 255, 255, 0.92));
      border-color: rgba(161, 72, 66, 0.28);
    }
    .key-status.replacing .key-status-title {
      color: var(--danger);
    }
    .key-status.replacing .key-status-copy {
      color: rgba(161, 72, 66, 0.88);
    }
    .key-status.replacing #statusReturnLink {
      display: none;
    }
    /* No key: strong warning (red) so it reads as blocked, not a soft prompt. */
    .key-status.unset {
      background: linear-gradient(180deg, rgba(243, 228, 226, 0.92), rgba(255, 255, 255, 0.92));
      border-color: rgba(161, 72, 66, 0.28);
    }
    .key-status.unset .key-status-title {
      color: var(--danger);
    }
    .key-status.unset .key-status-copy {
      color: rgba(161, 72, 66, 0.88);
    }
    /* Hosted credits fallback: informational blue, matches the brand accent gradient. */
    .key-status.hosted {
      background: linear-gradient(180deg, rgba(230, 238, 245, 0.92), rgba(255, 255, 255, 0.92));
      border-color: rgba(35, 66, 94, 0.28);
    }
    .key-status.hosted .key-status-title {
      color: var(--accent);
    }
    .key-status.hosted .key-status-copy {
      color: rgba(35, 66, 94, 0.82);
    }
    h1 {
      font-size: clamp(2rem, 4vw, 2.8rem);
      font-weight: 760;
      letter-spacing: -0.03em;
      line-height: 1.05;
      margin-bottom: 16px;
    }
    .api-key-title-mobile {
      display: none;
    }
    .lead {
      color: var(--muted);
      line-height: 1.72;
      font-size: 0.98rem;
      margin-bottom: 20px;
    }
    .field-shell {
      display: grid;
      gap: 16px;
      padding: 20px;
      border-radius: 26px;
      border: 1px solid rgba(35, 66, 94, 0.12);
      background:
        linear-gradient(180deg, rgba(230,238,245,0.58), rgba(255,255,255,0.92)),
        #ffffff;
      box-shadow: inset 0 1px 0 rgba(255,255,255,0.62);
    }
    .provider-tabs {
      display: grid;
      grid-template-columns: repeat(3, minmax(0, 1fr));
      gap: 8px;
    }
    .provider-tab {
      min-height: 46px;
      border-radius: 999px;
      border: 1px solid var(--line-strong);
      background: rgba(255, 255, 255, 0.58);
      color: var(--muted);
      font-weight: 760;
      opacity: 0.72;
      transition: border-color 0.16s ease, background 0.16s ease, color 0.16s ease, opacity 0.16s ease, box-shadow 0.16s ease;
    }
    .provider-tab.active {
      border-color: rgba(35, 66, 94, 0.46);
      background: #ffffff;
      color: var(--accent);
      opacity: 1;
      box-shadow:
        0 8px 18px rgba(35, 66, 94, 0.1),
        inset 0 0 0 1px rgba(35, 66, 94, 0.08);
    }
    .field-head {
      display: flex;
      justify-content: space-between;
      align-items: flex-start;
      gap: 12px;
      flex-wrap: wrap;
    }
    .field-label {
      font-size: 0.74rem;
      text-transform: uppercase;
      letter-spacing: 0.12em;
      color: #7a8390;
      font-weight: 700;
      margin-bottom: 8px;
    }
    .field-copy {
      color: var(--muted);
      line-height: 1.65;
    }
    .field-copy a {
      color: var(--accent);
      text-decoration: underline;
      font-weight: 700;
    }
    .input-row,
    .action-row {
      display: flex;
      gap: 12px;
      align-items: stretch;
      flex-wrap: wrap;
    }
    .api-input {
      flex: 1;
      min-width: 0;
      min-height: 60px;
      padding: 0 18px;
      border-radius: 20px;
      border: 1px solid var(--line-strong);
      background: rgba(255,255,255,0.98);
      outline: none;
      font-family: "Consolas", "SFMono-Regular", monospace;
      font-size: 0.98rem;
    }
    .api-input:focus {
      border-color: rgba(35, 66, 94, 0.42);
      box-shadow: 0 0 0 4px rgba(35, 66, 94, 0.08);
    }
    .btn {
      padding: 12px 18px;
      border: 1px solid transparent;
    }
    .btn-primary {
      background: var(--accent);
      color: #ffffff;
      box-shadow: 0 14px 28px rgba(35, 66, 94, 0.18);
    }
    .btn-success {
      background: var(--success);
      color: #ffffff;
      border-color: rgba(36, 102, 74, 0.36);
      box-shadow: 0 14px 28px rgba(36, 102, 74, 0.16);
    }
    .btn-ghost {
      background: rgba(255,255,255,0.84);
      color: var(--ink);
      border-color: var(--line-strong);
      box-shadow: none;
    }
    .btn-large {
      min-height: 56px;
      min-width: 190px;
      padding: 15px 24px;
    }
    .btn-primary:disabled,
    .btn-ghost:disabled,
    .btn-success:disabled {
      opacity: 0.45;
      cursor: not-allowed;
      transform: none;
      box-shadow: none;
    }
    .return-link {
      display: none;
    }
    .status-msg {
      display: none;
      font-size: 0.86rem;
      font-weight: 700;
      line-height: 1.5;
      padding: 13px 16px;
      border-radius: 16px;
    }
    /* Match .key-status.set / .key-status.unset — green when key is saved, red when removed or invalid. */
    .status-msg.success {
      color: var(--success);
      background: linear-gradient(180deg, rgba(228, 243, 234, 0.92), rgba(255, 255, 255, 0.92));
      border: 1px solid rgba(36, 102, 74, 0.26);
    }
    .status-msg.error {
      color: var(--danger);
      background: linear-gradient(180deg, rgba(243, 228, 226, 0.92), rgba(255, 255, 255, 0.92));
      border: 1px solid rgba(161, 72, 66, 0.28);
    }
    .spinner {
      display: inline-block;
      width: 14px;
      height: 14px;
      border: 2px solid rgba(255,255,255,0.35);
      border-top-color: #ffffff;
      border-radius: 50%;
      animation: spin 0.7s linear infinite;
    }
    @keyframes spin { to { transform: rotate(360deg); } }

    @media (max-width: 980px) {
      .nav {
        flex-wrap: wrap;
        align-items: center;
        gap: 14px;
      }
      .nav .brand {
        flex: 1;
        min-width: 0;
        order: 1;
      }
      .nav-menu-btn {
        display: inline-flex;
        order: 2;
      }
      .nav .nav-actions {
        order: 3;
        flex-basis: 100%;
        width: 100%;
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
      }
      .nav .nav-actions > .nav-link,
      .nav .nav-actions > .nav-pill {
        flex: none;
        width: 100%;
        min-height: 44px;
      }
      .nav .nav-actions > .nav-danger--desktop {
        display: none;
      }
      .nav-menu-panel {
        order: 4;
        flex-basis: 100%;
        width: 100%;
        display: none;
      }
      .nav.nav--open .nav-menu-panel {
        display: flex;
        flex-direction: column;
        gap: 8px;
      }
      .nav-menu-panel > .nav-danger {
        width: 100%;
        min-height: 44px;
      }
    }

    @media (max-width: 860px) {
      body { padding: 16px; }
    }

    @media (max-width: 640px) {
      .shell {
        padding: 18px 14px 16px;
      }
      .panel {
        padding: 22px;
        border-radius: 24px;
      }
      h1 {
        max-width: none;
      }
      .api-key-title-desktop {
        display: none;
      }
      .api-key-title-mobile {
        display: inline;
      }
      .lead {
        white-space: normal;
      }
      .field-shell {
        padding: 18px;
      }
      .field-copy {
        white-space: normal;
      }
      .input-row,
      .action-row {
        flex-direction: column;
      }
      .provider-tabs {
        grid-template-columns: 1fr;
      }
      .key-status {
        align-items: stretch;
      }
      .btn,
      .inline-link {
        width: 100%;
      }
      #statusReturnLink {
        display: none !important;
      }
      .api-input {
        font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
        font-size: 16px;
      }
    }

    @media (max-width: 480px) {
      body {
        padding:
          max(12px, env(safe-area-inset-top, 0px))
          max(12px, env(safe-area-inset-right, 0px))
          max(14px, env(safe-area-inset-bottom, 0px))
          max(12px, env(safe-area-inset-left, 0px));
        touch-action: manipulation;
      }
      .frame {
        border-radius: 22px;
      }
      .nav {
        padding: 16px 18px;
      }
      .nav-actions {
        gap: 8px;
      }
      .nav-link,
      .nav-danger {
        min-height: 44px;
      }
      .nav-danger {
        width: 100%;
      }
    }
