:root {
  color-scheme: light dark;

  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-muted: #f1f5f9;
  --surface-hover: #f8fafc;
  --field: #ffffff;

  --text: #0f172a;
  --text-muted: #64748b;

  --border: #e2e8f0;
  --border-strong: #cbd5e1;

  --accent: #334155;
  --accent-soft: #e2e8f0;
  --accent-contrast: #ffffff;

  --button: #2563eb;
  --button-hover: #1d4ed8;
  --button-contrast: #ffffff;

  --danger: #b42318;
  --danger-soft: #fef2f2;
  --danger-border: #fecaca;
  --danger-contrast: #ffffff;
  --success: #15803d;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-pill: 999px;

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 18px 40px -20px rgba(15, 23, 42, 0.28);
  --ring: 0 0 0 3px rgba(15, 23, 42, 0.16);

  --font-sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;

    --bg: #121215;
    --surface: #1d1d21;
    --surface-muted: #27272b;
    --surface-hover: #222226;
    --field: #151518;

    --text: #ededf0;
    --text-muted: #a1a1aa;

    --border: #2b2b31;
    --border-strong: #3f3f46;

    --accent: #d4d4d8;
    --accent-soft: rgba(212, 212, 216, 0.1);
    --accent-contrast: #0b0b0d;

    --button: #2563eb;
    --button-hover: #3b82f6;
    --button-contrast: #ffffff;

    --danger: #f87171;
    --danger-soft: rgba(248, 113, 113, 0.12);
    --danger-border: rgba(248, 113, 113, 0.3);
    --danger-contrast: #0b0b0d;
    --success: #4ade80;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 24px 48px -24px rgba(0, 0, 0, 0.7);
    --ring: 0 0 0 3px rgba(212, 212, 216, 0.2);
  }
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100svh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.page {
  display: flex;
  flex-direction: column;
  width: min(100%, 440px);
  min-height: 100svh;
  margin: 0 auto;
  padding: 24px 20px;
}

.site-header {
  margin-bottom: 20px;
  text-align: center;
}

.brand {
  display: inline-flex;
  align-items: center;
  color: var(--text);
  text-decoration: none;
}

.brand-logo {
  display: block;
  width: auto;
  height: 30px;
}

@media (prefers-color-scheme: dark) {
  .brand-logo {
    filter: invert(1);
  }
}

h1,
h2 {
  margin: 0 0 20px;
  font-size: 1.5rem;
  font-weight: 650;
  line-height: 1.25;
}

.card h1,
.card h2 {
  text-align: center;
}

h1:focus,
h2:focus {
  outline: none;
}

.lede {
  margin: 0 0 20px;
  color: var(--text-muted);
  font-size: 0.9375rem;
  line-height: 1.6;
}

.lede strong {
  color: var(--text);
  font-weight: 600;
}

.card p {
  text-align: center;
}

.card .url-preview,
.card .error-banner {
  text-align: left;
}

.card label {
  text-align: center;
}

.field {
  margin-bottom: 16px;
}

label {
  display: block;
  margin-bottom: 6px;
  font-size: 0.875rem;
  font-weight: 500;
}

input {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--field);
  color: var(--text);
  font: inherit;
  transition:
    border-color 0.15s ease,
    box-shadow 0.15s ease;
}

input::placeholder {
  color: var(--text-muted);
  opacity: 0.8;
}

input:hover:not(:disabled),
select:hover:not(:disabled) {
  border-color: var(--border-strong);
}

input:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: var(--ring);
  outline: none;
}

input:disabled,
select:disabled {
  background: var(--surface-muted);
  color: var(--text-muted);
  cursor: not-allowed;
}

.url-preview {
  display: inline-block;
  max-width: 100%;
  margin: 0;
  padding: 2px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-muted);
  color: var(--text-muted);
  overflow-wrap: anywhere;
  text-align: left;
}

.name-usage {
  display: grid;
  gap: 12px;
  margin-top: 12px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-muted);
  text-align: left;
}

.name-usage .name-usage-title {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 650;
  letter-spacing: 0.04em;
  text-align: left;
  text-transform: uppercase;
}

.name-usage-list {
  display: grid;
  gap: 12px;
  margin: 0;
}

.name-usage-row {
  display: grid;
  gap: 3px;
}

.name-usage-row dt {
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 500;
}

.name-usage-url {
  margin: 0;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.hint,
.status {
  margin: 4px 0 0;
  color: var(--text-muted);
  font-size: 0.875rem;
  line-height: 1.45;
}

.status:empty,
.hint:empty {
  display: none;
}

.terms {
  margin: 10px 0 0;
  color: var(--text-muted);
  font-size: 0.8125rem;
  line-height: 1.5;
}

.terms a {
  color: var(--accent);
  text-underline-offset: 2px;
}

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

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

.error-banner {
  margin: 0 0 16px;
  padding: 10px 12px;
  border: 1px solid var(--danger-border);
  border-radius: var(--radius-sm);
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 0.875rem;
  line-height: 1.45;
  text-align: left;
}

.button-primary {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 44px;
  padding: 10px 16px;
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--button);
  box-shadow: var(--shadow-sm);
  color: var(--button-contrast);
  font: inherit;
  font-size: 0.9375rem;
  font-weight: 600;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  transition:
    background 0.15s ease,
    box-shadow 0.15s ease,
    transform 0.15s ease;
}

.button-primary:hover:not(:disabled) {
  background: var(--button-hover);
  box-shadow: var(--shadow-md);
}

.button-primary:active:not(:disabled) {
  transform: translateY(1px);
}

.button-primary:focus-visible {
  outline: 2px solid var(--button);
  outline-offset: 2px;
}

.button-primary:disabled {
  background: var(--surface-muted);
  box-shadow: none;
  color: var(--text-muted);
  cursor: not-allowed;
}

.button-danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 8px 14px;
  border: 1px solid var(--danger-border);
  border-radius: var(--radius-sm);
  background: var(--danger-soft);
  color: var(--danger);
  font: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  transition:
    background 0.15s ease,
    border-color 0.15s ease,
    color 0.15s ease,
    transform 0.15s ease;
}

.button-danger:hover:not(:disabled) {
  border-color: var(--danger);
  background: var(--danger);
  color: var(--danger-contrast);
}

.button-danger:active:not(:disabled) {
  transform: translateY(1px);
}

.button-danger:focus-visible {
  outline: 2px solid var(--danger);
  outline-offset: 2px;
}

.button-danger:disabled {
  border-color: var(--border);
  background: var(--surface-muted);
  color: var(--text-muted);
  cursor: not-allowed;
}

.existing-access {
  margin-top: 16px;
}

.secondary {
  margin: 20px 0 0;
  color: var(--text-muted);
  font-size: 0.875rem;
}

.text-link {
  color: var(--accent);
  font-weight: 500;
  text-decoration: none;
  text-underline-offset: 2px;
}

.text-link:hover {
  text-decoration: underline;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  margin-top: 16px;
}

.link-button {
  padding: 0;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--accent);
  font: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: color 0.15s ease;
}

.link-button:hover:not(:disabled) {
  text-decoration: underline;
}

.link-button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.link-button:disabled,
.link-button.is-busy {
  color: var(--text-muted);
  cursor: not-allowed;
}

.notice {
  margin: 0 0 16px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-muted);
  color: var(--text-muted);
  font-size: 0.875rem;
  line-height: 1.5;
}

.shell {
  width: 100%;
}

.card {
  padding: clamp(24px, 5vw, 32px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-md);
}

.panel {
  margin: 0;
}

@media (max-width: 480px) {
  .page {
    padding: 16px;
  }

  .site-header {
    margin-bottom: 16px;
  }
}

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