:root {
  color-scheme: light;
  --ink: #171918;
  --muted: #656b67;
  --line: #cfd4d0;
  --paper: #ffffff;
  --canvas: #f2f4f1;
  --blue: #1457d9;
  --blue-dark: #0c3fa7;
  --coral: #b8442e;
  --green: #16734a;
  --yellow: #f0bc36;
  --radius: 6px;
}

* { box-sizing: border-box; }
html { font-family: Inter, "Noto Sans TC", "Microsoft JhengHei", sans-serif; color: var(--ink); background: var(--canvas); }
body { margin: 0; min-width: 300px; }
button, input, select, textarea { font: inherit; letter-spacing: 0; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: var(--blue); }
.hidden { display: none !important; }
.eyebrow { margin: 0 0 6px; color: var(--muted); font-size: 11px; font-weight: 800; letter-spacing: 0; }

.site-header {
  min-height: 58px;
  padding: 0 max(24px, calc((100vw - 1120px) / 2));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}
.brand { color: var(--ink); text-decoration: none; font-size: 21px; font-weight: 900; }
.brand span { color: var(--blue); }
.site-header nav, .site-footer nav { display: flex; align-items: center; gap: 18px; }
.site-header nav a, .site-footer a { color: #3f4441; text-decoration: none; font-size: 13px; font-weight: 650; }
.site-header nav a:hover, .site-footer a:hover { color: var(--blue); }
.nav-button, .quiet-button {
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--paper);
  color: var(--ink);
  padding: 7px 10px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
}

main { min-height: calc(100vh - 120px); }
.creator-band, .workspace-band { padding-left: max(24px, calc((100vw - 1120px) / 2)); padding-right: max(24px, calc((100vw - 1120px) / 2)); }
.creator-band { padding-top: 54px; padding-bottom: 56px; background: var(--paper); border-bottom: 1px solid var(--line); }
.creator-heading { display: flex; align-items: baseline; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.creator-heading .eyebrow { flex-basis: 100%; margin-bottom: -8px; }
h1, h2, p { overflow-wrap: anywhere; }
.creator-heading h1 { margin: 0; font-size: 34px; line-height: 1.15; letter-spacing: 0; }
.service-state { display: inline-flex; align-items: center; gap: 7px; font-size: 12px; color: var(--muted); }
.service-state i { width: 7px; height: 7px; border-radius: 50%; background: var(--green); }

.mode-switch { width: min(760px, 100%); display: grid; grid-template-columns: 1fr 1fr; border: 1px solid #aeb5b0; border-radius: var(--radius); overflow: hidden; }
.mode-switch button { min-height: 72px; padding: 13px 16px; text-align: left; border: 0; border-right: 1px solid #aeb5b0; background: #f6f7f5; cursor: pointer; }
.mode-switch button:last-child { border-right: 0; }
.mode-switch button[aria-selected="true"] { color: #fff; background: var(--blue); }
.mode-switch button[data-mode="direct"][aria-selected="true"] { background: #313634; }
.mode-switch strong, .mode-switch span { display: block; }
.mode-switch strong { font-size: 15px; }
.mode-switch span { margin-top: 4px; color: var(--muted); font-size: 12px; line-height: 1.35; }
.mode-switch button[aria-selected="true"] span { color: #dfe8ff; }

.creator-form { width: min(920px, 100%); margin-top: 26px; }
.creator-form > label, .direct-options label, .field label, .login-form label { display: block; margin-bottom: 7px; font-size: 12px; font-weight: 800; }
.creator-form label span { color: var(--muted); font-weight: 500; }
.url-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; }
input, select, textarea {
  width: 100%;
  border: 1px solid #9da49f;
  border-radius: 4px;
  background: #fff;
  color: var(--ink);
  outline: none;
}
input { min-height: 46px; padding: 0 13px; }
textarea { min-height: 130px; resize: vertical; padding: 12px 13px; line-height: 1.5; }
select { min-height: 44px; padding: 0 10px; }
input:focus, select:focus, textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(20, 87, 217, .13); }
.primary-action, .button {
  min-height: 44px;
  padding: 0 20px;
  border: 1px solid var(--blue-dark);
  border-radius: 4px;
  background: var(--blue);
  color: #fff;
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.primary-action:hover, .button.primary:hover { background: var(--blue-dark); }
.primary-action:disabled, button:disabled { cursor: wait; opacity: .58; }
.direct-options { margin-top: 18px; max-width: 420px; }
.slug-input { display: grid; grid-template-columns: 38px 1fr; }
.slug-input span { display: grid; place-items: center; border: 1px solid #9da49f; border-right: 0; border-radius: 4px 0 0 4px; background: #ecefeb; color: var(--muted); }
.slug-input input { border-radius: 0 4px 4px 0; }
.turnstile-slot { margin-top: 16px; min-height: 0; }
.turnstile-slot:not(:empty) { min-height: 65px; }
.form-status { min-height: 20px; margin: 12px 0 0; color: var(--coral); font-size: 13px; font-weight: 650; }

.result-panel { width: min(920px, 100%); margin-top: 28px; padding: 20px; display: grid; grid-template-columns: minmax(180px, .7fr) minmax(260px, 1fr); gap: 20px; border: 1px solid #aab7ad; border-left: 5px solid var(--green); border-radius: var(--radius); background: #f7faf8; }
.result-panel h2 { margin: 0; font-size: 18px; }
.result-panel p:not(.eyebrow) { margin: 7px 0 0; color: var(--muted); font-size: 13px; }
.result-url { display: flex; align-items: center; align-self: center; min-width: 0; border: 1px solid var(--line); border-radius: 4px; background: #fff; overflow: hidden; }
.result-url a { min-width: 0; flex: 1; padding: 11px 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.result-url button { align-self: stretch; border: 0; border-left: 1px solid var(--line); background: #edf0ed; padding: 0 13px; cursor: pointer; font-weight: 750; }
.progress-track { grid-column: 1 / -1; height: 4px; overflow: hidden; background: #dce1dd; }
.progress-track span { display: block; width: 42%; height: 100%; background: var(--yellow); animation: progress 1.7s ease-in-out infinite alternate; }
.progress-track.complete span { width: 100%; background: var(--green); animation: none; }
.progress-track.failed span { width: 100%; background: var(--coral); animation: none; }
@keyframes progress { from { transform: translateX(-60%); } to { transform: translateX(190%); } }

.workspace-band { padding-top: 40px; padding-bottom: 64px; }
.workspace-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.workspace-header h2 { margin: 0; font-size: 21px; }
.empty-state { padding: 32px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); color: var(--muted); font-size: 13px; }
.link-table, .admin-table { width: 100%; border-collapse: collapse; background: var(--paper); font-size: 13px; }
.link-table th, .link-table td, .admin-table th, .admin-table td { padding: 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.link-table th, .admin-table th { color: var(--muted); background: #e9ece9; font-size: 11px; text-transform: uppercase; }
.mode-badge { display: inline-block; padding: 3px 7px; border: 1px solid #a8b4aa; border-radius: 3px; font-size: 11px; font-weight: 750; }
.mode-badge.snapshot { color: var(--green); border-color: #87af99; background: #eff8f2; }
.mode-badge.direct { color: var(--coral); border-color: #c99a90; background: #fff3f0; }
.table-action { border: 1px solid #a7ada9; border-radius: 3px; background: #fff; padding: 5px 8px; cursor: pointer; font-size: 11px; font-weight: 700; }

dialog { width: min(430px, calc(100vw - 32px)); padding: 0; border: 1px solid #8e9690; border-radius: var(--radius); box-shadow: 0 22px 60px rgba(20, 24, 21, .22); }
dialog::backdrop { background: rgba(24, 28, 25, .52); }
.dialog-close { height: 34px; display: flex; justify-content: flex-end; }
.dialog-close button { width: 34px; border: 0; background: transparent; font-size: 25px; cursor: pointer; }
.login-form { padding: 2px 28px 28px; }
.login-form h2 { margin: 0 0 22px; font-size: 23px; }
.login-form .primary-action { width: 100%; margin-top: 4px; }

.site-footer { min-height: 62px; padding: 0 max(24px, calc((100vw - 1120px) / 2)); display: flex; align-items: center; justify-content: space-between; border-top: 1px solid var(--line); background: #e7eae7; color: var(--muted); font-size: 12px; }

.system-page { background: var(--canvas); }
.system-panel { width: min(720px, calc(100% - 40px)); min-height: 0; margin: 72px auto; padding: 32px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper); }
.system-panel h1 { margin: 0 0 14px; font-size: 30px; }
.system-panel p { color: #4f5551; line-height: 1.65; }
.system-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 24px; }
.button { min-height: 40px; }
.button:not(.primary):not(.danger) { color: var(--ink); border-color: #9ca39e; background: #fff; }
.button.danger { border-color: #923320; background: var(--coral); }
.destination { margin-top: 24px; padding: 14px; border-left: 4px solid var(--yellow); background: #f5f5ef; }
.destination span, .destination strong, .destination code { display: block; }
.destination span { color: var(--muted); font-size: 11px; }
.destination strong { margin: 3px 0 7px; }
.destination code { overflow-wrap: anywhere; color: #555b57; }
.technical { font-family: ui-monospace, Consolas, monospace; font-size: 12px; }

.page-shell { width: min(960px, calc(100% - 40px)); margin: 48px auto 80px; }
.page-shell.narrow { width: min(700px, calc(100% - 40px)); }
.page-heading { padding-bottom: 22px; border-bottom: 1px solid var(--line); }
.page-heading h1 { margin: 0; font-size: 30px; }
.page-heading p { margin: 9px 0 0; color: var(--muted); line-height: 1.55; }
.stack-form { margin-top: 28px; display: grid; gap: 18px; }
.field small { display: block; margin-top: 5px; color: var(--muted); }
.stack-form .primary-action { justify-self: start; }
.notice { padding: 14px; border-left: 4px solid var(--yellow); background: #f6f5ee; font-size: 13px; line-height: 1.55; }
.success-notice { border-left-color: var(--green); background: #eff8f2; }
.prose { margin-top: 28px; }
.prose h2 { margin: 30px 0 10px; font-size: 18px; }
.prose p, .prose li { color: #454a47; line-height: 1.7; }

.admin-toolbar { margin: 20px 0; display: flex; align-items: end; gap: 12px; flex-wrap: wrap; }
.admin-toolbar .field { min-width: 240px; }
.admin-section { margin-top: 38px; }
.admin-section h2 { font-size: 20px; }
.admin-table-wrap { overflow-x: auto; border: 1px solid var(--line); }
.admin-table td { max-width: 280px; overflow-wrap: anywhere; }
.admin-actions { display: flex; flex-wrap: wrap; gap: 5px; }
.admin-actions button { border: 1px solid #9da49f; border-radius: 3px; background: #fff; padding: 5px 7px; cursor: pointer; font-size: 11px; }
.status-pill { display: inline-block; padding: 3px 6px; border-radius: 3px; background: #e7ebe8; font-size: 11px; }

@media (max-width: 700px) {
  .site-header { padding: 12px 18px; align-items: flex-start; }
  .site-header nav { gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
  .site-header nav a { display: none; }
  .creator-band, .workspace-band { padding-left: 18px; padding-right: 18px; }
  .creator-band { padding-top: 34px; }
  .creator-heading h1 { font-size: 28px; }
  .mode-switch { grid-template-columns: 1fr; }
  .mode-switch button { border-right: 0; border-bottom: 1px solid #aeb5b0; }
  .mode-switch button:last-child { border-bottom: 0; }
  .url-row { grid-template-columns: 1fr; }
  .primary-action { width: 100%; }
  .result-panel { grid-template-columns: 1fr; }
  .progress-track { grid-column: auto; }
  .link-table th:nth-child(4), .link-table td:nth-child(4) { display: none; }
  .link-table th, .link-table td { padding: 10px 7px; }
  .site-footer { padding: 18px; }
  .system-panel { margin: 34px auto; padding: 24px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
