:root {
  --paper: #eef2f6;
  --surface: #f7f9fb;
  --surface-strong: #dfe7ef;
  --ink: #1d2a3a;
  --muted: #66778b;
  --line: #b8c6d5;
  --line-strong: #7f95ab;
  --accent: #bcd3eb;
  --accent-strong: #54799f;
  --danger: #a95c6b;
  --focus: #5f87b2;
  --page-width: 1160px;
  --control-width: 142px;
  --mobile-action-width: clamp(112px, 34vw, 142px);
  --primary-group-width: 105px;
  --mobile-rhythm: 72px;
  --input-height: 58px;
  --section-label-width: clamp(150px, 17vw, 210px);
  --section-gap: clamp(16px, 1.8vw, 24px);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--paper);
  font-synthesis: none;
}

:root[data-theme="dark"] {
  --paper: #1b222b;
  --surface: #232d39;
  --surface-strong: #2d3947;
  --ink: #edf2f6;
  --muted: #aab7c6;
  --line: #4b5b6d;
  --line-strong: #7890a8;
  --accent: #91b3d6;
  --accent-strong: #c0d8ef;
  --danger: #e2a0aa;
  --focus: #8db2dc;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--paper); color: var(--ink); transition: background .2s ease, color .2s ease; }
button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
::selection { background: var(--accent); color: var(--ink); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
.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; }

.workspace { min-height: 100vh; }
.content-wrap { width: min(calc(100% - 72px), var(--page-width)); min-height: 100svh; margin: 0 auto; padding: 72px 0 84px; display: flex; flex-direction: column; justify-content: center; }
.intro { display: flex; align-items: center; justify-content: space-between; width: min(100%, calc(var(--section-label-width) + var(--section-gap) + 780px)); gap: 24px; margin-bottom: clamp(48px, 7vh, 82px); }
.intro h1 { margin: 0; font-size: clamp(56px, 7.2vw, 98px); line-height: .92; letter-spacing: -.045em; font-weight: 780; white-space: nowrap; }
.theme-toggle { display: grid; place-items: center; flex: 0 0 44px; width: 44px; height: 44px; margin-right: 18px; padding: 0; border: 0; border-radius: 50%; color: var(--muted); background: transparent; }
.theme-toggle:hover { color: var(--ink); background: color-mix(in srgb, var(--surface-strong) 60%, transparent); }
.theme-icon { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.7; }
.theme-icon-moon { display: none; }
.theme-icon-sun { display: block; }
:root[data-theme="dark"] .theme-icon-moon { display: block; }
:root[data-theme="dark"] .theme-icon-sun { display: none; }

@media (min-width: 761px) {
  .theme-toggle { margin-right: calc((var(--control-width) - 44px) / 2); }
}

.tool-grid { display: grid; gap: clamp(54px, 7vh, 84px); align-items: start; }
.surface { background: transparent; }
.create-section, .query-section { display: grid; grid-template-columns: var(--section-label-width) minmax(0, 1fr); gap: var(--section-gap); align-items: start; }
.section-heading { display: block; padding: 0; }
.section-heading h2 { margin: 0 0 10px; font-size: 26px; line-height: 1.1; letter-spacing: -.045em; }
.section-heading span { display: block; max-width: 15ch; color: var(--muted); font-size: 14px; line-height: 1.45; }

.create-form, .query-form, .result-bar, .form-error, .query-error, .query-result { width: min(100%, 780px); }
.destination-row { display: grid; grid-template-columns: minmax(0, 1fr) var(--control-width); align-items: end; gap: 20px; }
.form-row { display: grid; grid-template-columns: minmax(0, 1fr) var(--control-width); align-items: end; gap: 20px; margin-top: 30px; }
.field label { display: block; margin-bottom: 10px; font-size: 14px; line-height: 1.2; font-weight: 700; }
.field label span { color: var(--muted); font-size: 12px; font-weight: 500; margin-left: 4px; }
.field-expiry > label { padding-left: calc((var(--control-width) - var(--primary-group-width)) / 2); }
.input-wrap { height: var(--input-height); display: flex; align-items: center; border: 0; border-bottom: 1px solid color-mix(in srgb, var(--line) 66%, transparent); background: transparent; transition: border-color .18s ease, box-shadow .18s ease; }
.input-wrap:focus-within { border-bottom-color: var(--accent-strong); box-shadow: 0 2px 0 color-mix(in srgb, var(--accent) 70%, transparent); }
.input-wrap input { width: 100%; height: 100%; padding: 0; border: 0; outline: 0; background: transparent; color: var(--ink); font-size: 15px; }
.input-wrap input::placeholder { color: var(--muted); opacity: .72; }
.field-prefix { color: var(--muted); font-size: 14px; white-space: nowrap; }
.slug-wrap input, .query-form .input-wrap input { padding-left: 0; }

.expiry-wrap { position: relative; width: var(--control-width); }
.expiry-trigger { display: flex; align-items: center; justify-content: space-between; width: 100%; height: 100%; padding: 0 0 0 calc((var(--control-width) - var(--primary-group-width)) / 2); border: 0; background: transparent; color: var(--ink); font-size: 15px; text-align: left; }
.expiry-trigger svg { width: 17px; height: 17px; fill: none; stroke: var(--muted); stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.5; transition: transform .18s ease; }
.expiry-trigger[aria-expanded="true"] svg { transform: rotate(180deg); }
.expiry-menu { position: absolute; top: calc(100% + 12px); right: 0; z-index: 4; width: min(280px, calc(100vw - 32px)); padding: 8px; border: 0; border-radius: 13px; background: var(--surface); box-shadow: 0 14px 34px rgba(31, 48, 68, .16); }
.expiry-menu button { display: block; width: 100%; padding: 11px 12px; border: 0; border-radius: 8px; background: transparent; color: var(--ink); font-size: 14px; text-align: left; transition: background .18s ease, color .18s ease, transform .18s ease; }
.expiry-menu button:hover { background: color-mix(in srgb, var(--accent) 45%, transparent); }
.expiry-menu button:hover { transform: translateX(3px); }
.custom-expiry-panel { padding: 8px 12px 10px; }
.custom-expiry-panel label { display: block; margin-bottom: 6px; color: var(--muted); font-size: 12px; }
.custom-expiry-panel input { width: 100%; padding: 8px 0; border: 0; border-bottom: 1px solid var(--line); outline: 0; background: transparent; color: var(--ink); font: inherit; font-size: 13px; }
.custom-expiry-panel input:focus { border-bottom-color: var(--accent-strong); }
.custom-expiry-apply { display: flex; align-items: center; justify-content: center; width: 100%; min-height: 34px; margin-top: 10px; padding: 0 12px; border: 0; border-radius: 8px; background: color-mix(in srgb, var(--accent) 48%, transparent); color: var(--accent-strong); font-size: 13px; font-weight: 700; text-align: center; transition: background .18s ease, color .18s ease; }
.custom-expiry-apply:hover { background: var(--accent); color: var(--ink); }
.custom-expiry-panel p { min-height: 16px; margin: 6px 0 0; color: var(--danger); font-size: 11px; }

.primary-button, .secondary-button { height: 54px; border: 0; border-radius: 11px; font-size: 14px; font-weight: 700; }
.primary-button { display: flex; align-items: center; justify-content: center; gap: 13px; width: var(--control-width); min-width: var(--control-width); padding: 0; background: transparent; color: var(--ink); transition: color .18s ease; }
.primary-button b { display: grid; place-items: center; flex: 0 0 36px; width: 36px; height: 36px; border-radius: 50%; background: var(--accent); color: var(--ink); transition: background .18s ease, color .18s ease, transform .18s ease; }
.primary-button b svg { display: block; width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.45; }
.primary-button:hover { color: var(--accent-strong); }
.primary-button:hover b { background: var(--accent-strong); color: var(--paper); transform: translateX(3px); }
.primary-button:disabled { opacity: .6; cursor: wait; }
.secondary-button { display: inline-flex; align-items: center; justify-content: center; width: var(--control-width); min-width: var(--control-width); padding: 0 14px; background: color-mix(in srgb, var(--surface-strong) 70%, transparent); color: var(--accent-strong); transition: background .18s ease, color .18s ease, transform .18s ease; }
.secondary-button:hover { background: var(--accent); color: var(--ink); transform: translateY(-1px); }

.form-error, .query-error { min-height: 20px; margin: 12px 0 0; color: var(--danger); font-size: 13px; }
.form-error, .result-bar, .query-error, .query-result { grid-column: 2; }
.result-bar { display: flex; align-items: center; gap: 15px; min-height: 48px; margin-top: 20px; padding: 10px 0; animation: reveal .22s ease-out both; }
.result-label { display: flex; align-items: center; gap: 8px; white-space: nowrap; font-size: 13px; }
.result-label i { display: block; width: 8px; height: 8px; border-radius: 50%; background: var(--accent-strong); }
.result-url { min-width: 0; flex: 1; overflow: hidden; color: var(--accent-strong); font-size: 13px; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.copy-button { padding: 4px 2px; border: 0; background: transparent; color: var(--accent-strong); font-size: 13px; font-weight: 760; }
.copy-button:hover { text-decoration: underline; text-underline-offset: 3px; }

.query-form { display: grid; grid-template-columns: minmax(0, 1fr) var(--control-width); align-items: end; gap: 20px; }
.query-form .secondary-button { justify-self: end; align-self: end; }
.query-error { margin: 12px 0 0; }
.query-result { display: grid; grid-template-columns: 1fr; gap: 8px; align-items: center; margin: 22px 0 0; padding: 16px 0 0; font-size: 13px; }
.query-result > span { color: var(--muted); }
.query-result a { overflow: hidden; color: var(--accent-strong); font-size: 14px; font-weight: 650; text-overflow: ellipsis; white-space: nowrap; }

.toast { position: fixed; right: 24px; bottom: 23px; z-index: 3; display: flex; align-items: center; gap: 9px; padding: 12px 16px; border: 0; border-radius: 12px; background: var(--surface); color: var(--ink); font-size: 13px; font-weight: 700; box-shadow: 0 8px 22px rgba(20, 34, 50, .15); opacity: 0; pointer-events: none; transform: translateY(14px); transition: opacity .2s ease, transform .2s ease; }
.toast.is-visible { opacity: 1; transform: translateY(0); }
.toast-mark { display: grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; background: var(--accent-strong); color: var(--surface); font-size: 11px; }

@keyframes reveal { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: translateY(0); } }

@media (max-width: 899px) {
  .content-wrap { width: min(calc(100% - 56px), 760px); }
}

@media (max-width: 760px) {
  .content-wrap { width: min(calc(100% - 40px), 560px); min-height: 100svh; padding: 48px 0 64px; }
  .intro { margin-bottom: var(--mobile-rhythm); }
  .intro h1 { font-size: 58px; }
  .tool-grid { gap: 72px; }
  .create-section, .query-section { grid-template-columns: 1fr; gap: 22px; }
  .section-heading h2 { margin-bottom: 7px; font-size: 24px; line-height: 1.1; }
  .section-heading span { max-width: none; line-height: 1.45; }
  .form-error, .result-bar, .query-error, .query-result { grid-column: 1; }
  .form-error { min-height: 0; margin-top: 0; }
  .form-error:not(:empty) { min-height: 20px; margin-top: 12px; }
  .destination-row { grid-template-columns: minmax(0, 1fr) var(--mobile-action-width); gap: 12px; }
  .form-row { grid-template-columns: minmax(0, 1fr) var(--mobile-action-width); gap: 12px; margin-top: 24px; }
  .expiry-wrap { width: 100%; }
  .field label { margin-bottom: 8px; }
  .field-expiry > label { padding-left: calc((var(--mobile-action-width) - var(--primary-group-width)) / 2); }
  .expiry-trigger { padding-left: calc((var(--mobile-action-width) - var(--primary-group-width)) / 2); }
  .input-wrap { height: 52px; }
  .primary-button, .secondary-button { height: 50px; }
  .destination-row .primary-button, .query-form .secondary-button { width: 100%; min-width: 0; }
  .result-bar { flex-wrap: wrap; gap: 9px; }
  .result-url { flex-basis: 100%; order: 3; }
  .copy-button { margin-left: auto; }
  .query-form { grid-template-columns: minmax(0, 1fr) var(--mobile-action-width); gap: 12px; }
  .query-form .secondary-button { justify-self: start; }
  .query-result { grid-template-columns: 1fr; gap: 7px; }
  .toast { right: 16px; bottom: 16px; left: 16px; justify-content: center; }
}

@media (max-width: 420px) {
  .content-wrap { width: min(calc(100% - 32px), 560px); padding-top: 36px; }
  .intro h1 { font-size: 48px; }
  .field label { font-size: 13px; }
  .field label span { margin-left: 3px; font-size: 11px; }
}

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