/* Design tokens and base styles follow tsukii.cn, shared with pastebin. */
:root {
  color-scheme: light;
  --bg: #faf9f7;
  --surface: #fff;
  --text: #36332f;
  --muted: #76706b;
  --line: #e6e2dd;
  --accent: #95616d;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #222120; --surface: #292725; --text: #e6e2dd; --muted: #afa8a0; --line: #3b3733; --accent: #d6a5af;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #222120; --surface: #292725; --text: #e6e2dd; --muted: #afa8a0; --line: #3b3733; --accent: #d6a5af;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif; font-size: 15px; line-height: 1.9; -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; text-underline-offset: 5px; }
a:hover { text-decoration: underline; }
a span[aria-hidden] { display: inline-block; margin-left: 5px; font-size: .85em; }
button { font: inherit; }
code { font-family: ui-monospace, "SF Mono", "Cascadia Code", Consolas, "Courier New", monospace; font-size: .92em; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }
::selection { background: var(--accent); color: var(--bg); }
[hidden] { display: none !important; }

.wrap { max-width: 984px; padding: 0 32px; margin: 0 auto; }
/* Click particles. Fixed and non-interactive so it never blocks the UI. */
.click-fireworks { position: fixed; inset: 0; z-index: 100; width: 100vw; height: 100vh; height: 100dvh; pointer-events: none; }

/* header — three flat children: brand menu, section nav, account block */
.topbar { min-height: 104px; display: flex; align-items: center; justify-content: space-between; gap: 24px; border-bottom: 1px solid var(--line); flex-wrap: wrap; padding: 14px 0; }
.topbar__brand { flex: 0 0 auto; min-width: 0; }
.topbar__account { display: flex; align-items: center; gap: 26px; flex: 0 0 auto; margin-left: auto; }
/* Both controls sit on the same optical line: the chip is 24px tall inside a
   30px tap target, the theme button is 32px. Pinning both to 32px centres them
   against each other instead of leaving a 4px offset. */
.topbar__account > .menu { display: flex; align-items: center; }
.user-chip { min-height: 32px; }
.wordmark { color: var(--text); font-size: 19px; font-weight: 600; letter-spacing: -.5px; }
.caret { margin-left: 5px; opacity: .6; }

.menu { position: relative; }
.menu__trigger { display: inline-flex; align-items: center; gap: 8px; padding: 0; background: none; border: 0; cursor: pointer; }
/* The gap between the trigger and the panel is bridged with a transparent
   strip, otherwise moving the pointer down through it closes the menu. */
.menu__panel { position: absolute; top: 100%; left: 0; z-index: 20; display: none; min-width: 152px; padding: 6px; margin-top: 8px; background: var(--surface); border: 1px solid var(--line); border-radius: 6px; box-shadow: 0 8px 24px rgba(0, 0, 0, .08); }
.menu__panel::before { content: ""; position: absolute; left: 0; right: 0; top: -10px; height: 10px; }
.menu__panel--right { left: auto; right: 0; }
.menu.is-open .menu__panel { display: block; }
.menu__panel a, .menu__item { display: block; width: 100%; padding: 6px 10px; font-size: 13px; color: var(--text); text-align: left; background: none; border: 0; border-radius: 4px; cursor: pointer; text-decoration: none; white-space: nowrap; }
.menu__panel a:hover, .menu__item:hover { background: var(--bg); color: var(--accent); text-decoration: none; }
.menu__who { padding: 6px 10px 9px; border-bottom: 1px solid var(--line); margin-bottom: 4px; display: flex; flex-direction: column; max-width: 210px; }
.menu__login { font-size: 13px; color: var(--text); }
.menu__email { font-size: 11px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; }

/* Section tabs: the active one is marked by a straight bar underneath. */
.topnav { display: flex; align-items: center; gap: 30px; flex-wrap: wrap; }
.topnav__link { position: relative; padding: 0 0 6px; font-size: 13px; color: var(--muted); }
.topnav__link:hover { color: var(--accent); text-decoration: none; }
.topnav__link.is-active { color: var(--text); }
.topnav__link.is-active::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 2px; background: var(--accent); }

.user-chip { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text); }
.user-chip__avatar { width: 24px; height: 24px; border-radius: 50%; display: block; }
.user-chip__name { max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-chip:hover .user-chip__name { color: var(--accent); }
.inline-form { display: inline; margin: 0; }
.nav-button { padding: 0; font-size: 13px; color: var(--muted); background: none; border: 0; cursor: pointer; }
.theme-toggle { width: 32px; height: 32px; display: grid; place-items: center; padding: 0; color: var(--muted); background: none; border: 0; cursor: pointer; border-radius: 4px; flex-shrink: 0; }
.theme-toggle:hover { color: var(--accent); }

main { padding: 40px 0 64px; }
h2 { font-size: 25px; line-height: 1.4; font-weight: 500; letter-spacing: -.6px; margin: 0 0 18px; }
h3 { margin: 0 0 3px; font-size: 16px; font-weight: 500; overflow-wrap: anywhere; }
.footer { display: flex; justify-content: space-between; gap: 16px; border-top: 1px solid var(--line); padding: 21px 0 30px; color: var(--muted); font-size: 11px; }
.muted { color: var(--muted); font-weight: 400; }

/* forms */
.field { display: block; width: 100%; background: var(--surface); color: var(--text); border: 1px solid var(--line); border-radius: 4px; padding: 10px 14px; font: inherit; }
.field::placeholder { color: var(--muted); }
.field:focus, .field:focus-visible { outline: none; border-color: var(--accent); }
.field--title { margin-bottom: 12px; }
.title-row { display: flex; gap: 12px; align-items: stretch; margin-bottom: 12px; }
.title-row .field { margin: 0; }
.title-row input[name="title"] { flex: 1 1 auto; min-width: 0; }
.field--expiry { flex: 0 0 auto; width: auto; min-width: 170px; }
.field--custom { margin-bottom: 12px; }
.options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-bottom: 12px; }
.editor-actions { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-top: 14px; }
.hint { font-size: 12px; color: var(--muted); }

.button { display: inline-block; padding: 7px 18px; font-size: 13px; line-height: 1.8; background: var(--accent); color: var(--bg); border: 1px solid var(--accent); border-radius: 4px; cursor: pointer; }
.button:hover { opacity: .88; text-decoration: none; }
.button--ghost { background: var(--surface); border-color: var(--line); color: var(--text); }
.button--ghost:hover { opacity: 1; border-color: var(--accent); color: var(--accent); }
.button--small { padding: 3px 12px; font-size: 12px; }
.button[disabled] { opacity: .45; cursor: default; }
.link-button { padding: 0; font-size: inherit; color: var(--accent); background: none; border: 0; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }

/* login */
.auth { max-width: 420px; margin: 0 auto; padding: 9vh 0 4vh; text-align: center; }
.auth__logo { display: block; width: 56px; height: 56px; margin: 0 auto 16px; fill: var(--accent); }
.auth__title { font-size: 30px; letter-spacing: -1px; margin: 0 0 6px; }
.auth__lede { margin: 0 0 30px; color: var(--muted); font-size: 14px; }
.auth__primary { display: inline-flex; align-items: center; justify-content: center; gap: 9px; width: 100%; padding: 10px 18px; }
.auth__dev { display: flex; gap: 10px; margin-top: 22px; }
.auth__dev .field { flex: 1; }
.auth__hint { margin: 10px 0 0; font-size: 11px; color: var(--muted); }
.auth .notice { text-align: left; }

/* dropzone + progress */
.dropzone { display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 34px 20px; background: var(--surface); border: 1px dashed var(--line); border-radius: 4px; text-align: center; transition: border-color .15s; }
.dropzone.is-dragging { border-color: var(--accent); }
.dropzone.is-busy { opacity: .55; pointer-events: none; }
.dropzone__hint { margin: 0; color: var(--muted); font-size: 14px; }
.dropzone__actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.chip { padding: 4px 14px; font-size: 12px; color: var(--muted); background: var(--bg); border: 1px solid var(--line); border-radius: 999px; cursor: pointer; }
.chip:hover { color: var(--accent); border-color: var(--accent); }

/* Quota meters above the deployments list. */
.meters { display: grid; gap: 10px; margin-bottom: 30px; padding: 16px 18px; background: var(--surface); border: 1px solid var(--line); border-radius: 4px; }
.meter { display: grid; grid-template-columns: 150px minmax(0, 1fr) auto; align-items: center; gap: 14px; font-size: 12px; }
.meter__label { color: var(--muted); }
.meter__track { height: 6px; background: var(--bg); border-radius: 999px; overflow: hidden; }
.meter__fill { display: block; height: 100%; background: var(--accent); border-radius: 999px; }
.meter__value { color: var(--text); font-variant-numeric: tabular-nums; }

.progress { position: relative; height: 22px; margin-top: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 4px; overflow: hidden; }
.progress__bar { height: 100%; width: 0; background: var(--accent); opacity: .22; transition: width .12s linear; }
.progress__label { position: absolute; inset: 0; display: grid; place-items: center; font-size: 11px; color: var(--text); }

.quota { margin: 14px 0 0; font-size: 12px; color: var(--muted); }

/* deployment list */
.list-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 6px; }
.list-head h2 { margin-bottom: 12px; }
.view-toggle { display: inline-flex; border: 1px solid var(--line); border-radius: 4px; overflow: hidden; }
.view-toggle button { padding: 4px 14px; font-size: 12px; color: var(--muted); background: var(--surface); border: 0; cursor: pointer; }
.view-toggle button + button { border-left: 1px solid var(--line); }
.view-toggle button[aria-pressed="true"] { color: var(--bg); background: var(--accent); }

.deploy-list { list-style: none; padding: 0; margin: 0; }
.deploy-list li { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 18px 0; border-top: 1px solid var(--line); }
.deploy-list li:first-child { border-top: 0; }
.deploy-main { min-width: 0; }
.deploy-meta { margin: 0; font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.deploy-facts { display: block; font-size: 12px; color: var(--muted); }
.deploy-warn { margin: 6px 0 0; font-size: 12px; color: var(--accent); }
.deploy-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.deploy-actions form { margin: 0; }

.deploy-list[data-view="grid"] { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.deploy-list[data-view="grid"] li { flex-direction: column; align-items: stretch; gap: 10px; padding: 16px; border: 1px solid var(--line); border-radius: 4px; background: var(--surface); }
.deploy-list[data-view="grid"] li:first-child { border-top: 1px solid var(--line); }
.deploy-list[data-view="grid"] .deploy-actions { width: 100%; }

.empty { margin: 0; color: var(--muted); font-size: 14px; }
.notice { margin: 0 0 16px; padding: 8px 14px; background: var(--surface); border: 1px solid var(--line); border-left: 3px solid var(--accent); color: var(--muted); font-size: 13px; }
.notice--error { color: var(--text); }

/* admin */
.admin-layout { display: grid; grid-template-columns: 190px minmax(0, 1fr); gap: 40px; align-items: start; }
.sidebar { display: flex; flex-direction: column; gap: 12px; position: sticky; top: 24px; }
.sidebar__link { position: relative; padding: 0 0 6px; font-size: 13px; color: var(--muted); }
.sidebar__link:hover { color: var(--accent); text-decoration: none; }
.sidebar__link.is-active { color: var(--text); }
.sidebar__link.is-active::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 2px; background: var(--accent); }
.admin-main h2 { margin-bottom: 10px; }
.admin-main .hint { display: block; margin: 0 0 22px; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin-bottom: 12px; }
.stat { display: flex; flex-direction: column; gap: 2px; padding: 14px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 4px; }
.stat__label { font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.stat__value { font-size: 21px; font-weight: 500; letter-spacing: -.4px; }

.admin-block { margin-top: 34px; padding-top: 24px; border-top: 1px solid var(--line); }
.admin-block h3 { font-size: 15px; margin-bottom: 12px; }
.settings-form { max-width: 480px; }
.settings-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 6px 0; font-size: 13px; }
.settings-row__field { display: inline-flex; align-items: center; gap: 8px; }
.settings-row__field .field { width: 92px; padding: 5px 10px; text-align: right; }
.settings-row__unit { width: 44px; font-size: 12px; color: var(--muted); }

.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th { text-align: left; font-weight: 500; font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); padding: 0 12px 8px 0; border-bottom: 1px solid var(--line); }
.table td { padding: 9px 12px 9px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tbody tr:last-child td { border-bottom: 0; }
.table__action { width: 1%; white-space: nowrap; }
.table__action form { margin: 0; }

/* 404 / error page — same shape as tsukii.cn/404.html: the wrap fills the
   viewport, the message sits in the optical centre, header and footer stay put. */
.skip-link { position: absolute; top: -80px; left: 16px; padding: 8px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 4px; color: var(--text); z-index: 10; }
.skip-link:focus { top: 12px; }
.error-page .wrap { min-height: 100svh; display: flex; flex-direction: column; }
.error-page .topbar, .error-page .footer { flex-shrink: 0; }
.not-found { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 64px 0 80px; }
.not-found h1 { margin: 0; font-size: clamp(28px, 5vw, 36px); font-weight: 500; }
.not-found__text { max-width: 360px; margin: 18px 0 24px; color: var(--muted); font-size: 14px; }
.not-found__link { font-size: 14px; }
.landing { max-width: 620px; }

@media (max-width: 760px) {
  .admin-layout { grid-template-columns: 1fr; gap: 18px; }
  .sidebar { flex-direction: row; flex-wrap: wrap; gap: 18px; position: static; border-bottom: 1px solid var(--line); padding-bottom: 8px; }
  .meter { grid-template-columns: 1fr auto; }
  .meter__track { grid-column: 1 / -1; }
}

@media (max-width: 720px) {
  /* Two rows: brand + account on the first, section tabs on the second.
     The header is a flat flex container, so the nav simply gets a 100% flex
     basis and wraps; nothing needs to be pulled out of a wrapper.
     Note: `display: contents` is deliberately not used — it made the account
     menu unclickable because the browser drops the box the trigger lived in. */
  .topbar { min-height: 0; padding: 12px 0 0; gap: 8px 10px; align-items: center; }
  .topbar__brand { order: 1; flex: 0 1 auto; min-width: 0; }
  .topbar__account { order: 2; gap: 8px; margin-left: auto; align-items: center; }
  /* No divider line above the tabs on mobile — it read as a stray rule. */
  .topnav { order: 3; flex: 1 1 100%; justify-content: flex-start; gap: 22px; padding: 8px 0 8px; border-top: 0; }
  .topnav__link { font-size: 13px; }
  /* The caret is only useful on desktop, where there is room for it. */
  .caret { display: none; }
  .wordmark { font-size: 17px; }
  /* The account panel must never hang off the right edge on a narrow screen. */
  .menu__panel { max-width: calc(100vw - 40px); }
  .menu__panel--right { right: 0; }
  .menu__who { max-width: none; }
  .menu__email { white-space: normal; overflow-wrap: anywhere; }
  .user-chip__name { max-width: 92px; }
}

@media (max-width: 600px) {
  .wrap { padding: 0 20px; }
  main { padding: 24px 0 42px; }
  .title-row { flex-direction: column; }
  .field--expiry { width: 100%; }
  .options { grid-template-columns: 1fr; }
  .editor-actions { flex-direction: column-reverse; align-items: stretch; }
  .editor-actions .button { text-align: center; }
  .deploy-list li { flex-direction: column; gap: 10px; }
  .deploy-actions { width: 100%; }
  .deploy-actions .button { flex: 1; text-align: center; }
  .auth { padding-top: 4vh; }
  .table th:nth-child(4), .table td:nth-child(4) { display: none; }
  .dropzone { padding: 26px 14px; }
  .dropzone__hint { font-size: 13px; }
  .not-found { padding: 44px 0 60px; }
}

@media (max-width: 420px) {
  /* Below this width the name is dropped, but the button must stay tappable —
     an account with no avatar (e.g. the local dev login) would otherwise
     collapse it to 0×0 and make sign-out unreachable. The ::after dot is the
     guaranteed fallback target; a real avatar renders on top of it. */
  .user-chip { position: relative; min-width: 30px; min-height: 30px; justify-content: center; }
  .user-chip__name { display: none; }
  .user-chip::after {
    content: "";
    position: absolute;
    inset: 3px;
    border-radius: 50%;
    background: var(--accent);
    opacity: .3;
    z-index: 0;
  }
  .user-chip__avatar { position: relative; z-index: 1; }
  .menu__who { display: flex; }
  /* The wordmark is the widest item on a 320px row; let it truncate rather than
     push the account block onto a third line (which also pushed the panel
     off-screen to the left). */
  .wordmark { max-width: calc(100vw - 150px); overflow: hidden; text-overflow: ellipsis; }
  .meter { grid-template-columns: 1fr; }
  .meter__value { text-align: right; }
}
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } .progress__bar { transition: none; } }