:root {
  color-scheme: light;
  --bg: #f7f9fc;
  --surface: #ffffff;
  --surface-muted: #f1f5f9;
  --ink: #111827;
  --muted: #667085;
  --line: #dce6f9;
  --line-strong: #b8c7dd;
  --brand: #0b326b;
  --brand-hover: #082758;
  --brand-soft: rgba(19, 60, 130, 0.08);
  --accent: #27b4ff;
  --accent-soft: #e7f7ff;
  --link: #133c82;
  --danger: #b42318;
  --danger-bg: #fff4f2;
  --ok: #067647;
  --ok-bg: #ecfdf3;
  --shadow: 0 18px 42px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "DM Sans", "Segoe UI", Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.45;
  letter-spacing: 0;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: wait;
  opacity: 0.65;
}

a {
  color: inherit;
}

.hidden {
  display: none !important;
}

.login-screen,
.system-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-screen {
  background: #0b326b;
}

.login-container,
.system-box {
  width: min(410px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 28px;
}

.login-container {
  position: relative;
  overflow: hidden;
  text-align: left;
}

.login-container::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 6px;
  background: var(--accent);
}

.login-logo {
  width: min(220px, 78%);
  height: auto;
  margin: 0 auto 14px;
  display: block;
}

.login-container h1,
.system-box h1 {
  margin: 0;
  line-height: 1.2;
  font-weight: 650;
}

.login-container h1 {
  font-family: "Josefin Sans", "DM Sans", sans-serif;
  font-size: 30px;
  letter-spacing: 0.02em;
}

.login-subtitle,
.system-box p {
  margin: 8px 0 22px;
  color: var(--muted);
  font-size: 15px;
}

.social-login {
  display: grid;
  gap: 10px;
}

.provider-btn {
  width: 100%;
  min-height: 46px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  font-size: 15px;
  font-weight: 600;
  transition: background 140ms ease, border-color 140ms ease;
}

.provider-btn:hover {
  background: var(--surface-muted);
  border-color: var(--line-strong);
}

.provider-btn img,
.provider-btn svg {
  width: 21px;
  height: 21px;
  object-fit: contain;
  flex: 0 0 auto;
}

.subtle-provider {
  background: var(--surface-muted);
}

.email-auth-form {
  display: grid;
  gap: 10px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.email-auth-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.donate-link {
  width: fit-content;
  margin: 14px auto 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
}

.donate-link:hover {
  color: var(--brand);
}

.donate-link svg {
  width: 15px;
  height: 15px;
  color: var(--accent);
}

.login-message,
.form-message {
  min-height: 20px;
  margin: 14px 0 0;
  color: var(--danger);
  font-size: 14px;
}

.system-box {
  text-align: center;
}

.system-box h1 {
  font-size: 26px;
}

.app-shell {
  min-height: 100vh;
  background: var(--bg);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}

.topbar-inner {
  width: min(1180px, 100%);
  min-height: 64px;
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.brand-mark img {
  width: 68px;
  max-width: none;
  height: 68px;
  object-fit: cover;
  object-position: top center;
  transform: translateY(-3px);
}

.brand h1 {
  margin: 0;
  font-family: "Josefin Sans", "DM Sans", sans-serif;
  font-size: 17px;
  line-height: 1.15;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.brand p,
.section-heading p,
#redirectCount {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.top-actions,
.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.top-actions {
  min-width: 0;
}

.donate-button {
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
}

.donate-button:hover {
  color: var(--brand);
  border-color: var(--line-strong);
  background: var(--surface-muted);
}

.donate-button svg {
  width: 15px;
  height: 15px;
  color: var(--accent);
}

.user-chip {
  min-width: 0;
  max-width: 280px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.user-chip img {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #eef2f7;
}

.user-chip span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.workspace {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 18px 20px 24px;
  display: grid;
  grid-template-columns: minmax(300px, 380px) minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

.editor-panel,
.list-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}

.editor-panel {
  position: sticky;
  top: 82px;
}

.section-heading {
  margin-bottom: 14px;
}

.section-heading h2 {
  margin: 0;
  font-size: 18px;
  line-height: 1.25;
  font-weight: 650;
}

.redirect-form {
  display: grid;
  gap: 12px;
}

.field {
  display: grid;
  gap: 6px;
  color: var(--ink);
  font-weight: 600;
}

.field > span,
.field > label,
.toggle-row span {
  font-size: 13px;
}

.field-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.field-label em {
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--brand);
  font-size: 11px;
  font-style: normal;
  font-weight: 800;
}

.field input {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  color: var(--ink);
  background: #fff;
}

.field input::placeholder {
  color: #98a2b3;
}

.field input:focus {
  outline: 2px solid rgba(39, 180, 255, 0.24);
  border-color: var(--brand);
}

.path-input {
  display: grid;
  grid-template-columns: minmax(0, auto) minmax(120px, 1fr);
  align-items: center;
  border: 2px solid rgba(19, 60, 130, 0.28);
  border-radius: 6px;
  overflow: hidden;
  background: #fff;
}

.path-input span {
  height: 42px;
  max-width: 230px;
  display: flex;
  align-items: center;
  padding: 0 10px;
  overflow: hidden;
  color: var(--muted);
  background: var(--surface-muted);
  border-right: 1px solid var(--line);
  font-size: 13px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.path-input input {
  min-width: 0;
  border: 0;
  border-radius: 0;
}

.path-input input:focus {
  outline: 0;
}

.path-input:focus-within {
  outline: 2px solid rgba(39, 180, 255, 0.24);
  border-color: var(--brand);
}

.path-field.auto-mode .path-input {
  background: var(--surface-muted);
}

.path-field.auto-mode .path-input input {
  color: var(--muted);
  background: var(--surface-muted);
}

.path-options {
  display: flex;
  align-items: center;
}

.auto-toggle {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: fit-content;
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
}

.auto-toggle input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.auto-slider {
  width: 44px;
  height: 24px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: #e5edf8;
  transition: background 140ms ease, border-color 140ms ease;
}

.auto-slider::after {
  content: "";
  width: 18px;
  height: 18px;
  position: absolute;
  left: 3px;
  top: 3px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.22);
  transition: transform 140ms ease;
}

.auto-toggle input:checked + .auto-slider {
  background: var(--brand);
  border-color: var(--brand);
}

.auto-toggle input:checked + .auto-slider::after {
  transform: translateX(20px);
}

.auto-toggle input:focus-visible + .auto-slider {
  outline: 2px solid rgba(39, 180, 255, 0.34);
  outline-offset: 2px;
}

.field-help,
.field-status {
  margin: 0;
  font-size: 12px;
  font-weight: 500;
}

.field-help {
  color: var(--muted);
}

.field-status {
  min-height: 17px;
}

.field-status.ok {
  color: var(--ok);
}

.field-status.error {
  color: var(--danger);
}

.field-status.hint {
  color: var(--muted);
}

.toggle-row {
  display: flex;
  align-items: center;
  gap: 8px;
  width: fit-content;
  color: var(--ink);
  font-weight: 600;
}

.toggle-row input {
  width: 18px;
  height: 18px;
  accent-color: var(--brand);
}

.primary-action,
.secondary-action,
.icon-button,
.text-button {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 12px;
  background: #fff;
  color: var(--ink);
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  line-height: 1;
  transition: background 140ms ease, border-color 140ms ease, color 140ms ease;
}

.primary-action {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

.primary-action:hover {
  background: var(--brand-hover);
  border-color: var(--brand-hover);
}

.secondary-action:hover,
.icon-button:hover,
.text-button:hover {
  background: var(--surface-muted);
  border-color: var(--line-strong);
}

.compact {
  min-height: 32px;
  padding: 6px 10px;
  font-size: 13px;
}

.wide {
  width: 100%;
}

.icon-button {
  width: 36px;
  padding: 0;
}

.icon-button svg,
.primary-action svg,
.secondary-action svg,
.text-button svg {
  width: 17px;
  height: 17px;
  flex: 0 0 auto;
}

.empty-state {
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  padding: 28px 16px;
  text-align: center;
  color: var(--muted);
  background: var(--surface-muted);
}

.empty-state h3 {
  margin: 0 0 6px;
  color: var(--ink);
  font-size: 16px;
  font-weight: 650;
}

.empty-state p {
  margin: 0;
}

.redirect-list {
  display: grid;
  gap: 10px;
}

.redirect-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.locked-card {
  background: #fcfdff;
}

.redirect-main {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.redirect-label {
  margin: 0;
  font-size: 15px;
  line-height: 1.3;
  font-weight: 650;
}

.redirect-url,
.destination-url {
  overflow-wrap: anywhere;
}

.redirect-url {
  width: fit-content;
  color: var(--link);
  font-size: 14px;
  font-weight: 600;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.redirect-url:hover {
  color: #1f4d94;
}

.destination-url {
  color: var(--muted);
  font-size: 13px;
}

.redirect-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
}

.status-pill {
  border-radius: 999px;
  padding: 3px 8px;
  font-weight: 600;
}

.status-pill.active {
  color: var(--ok);
  background: var(--ok-bg);
}

.status-pill.inactive {
  color: var(--danger);
  background: var(--danger-bg);
}

.locked-note {
  color: var(--muted);
  background: var(--surface-muted);
  border-radius: 999px;
  padding: 3px 8px;
  font-weight: 700;
}

.redirect-actions {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.text-button {
  min-height: 32px;
  padding: 7px 10px;
}

.danger-action {
  color: var(--danger);
  border-color: #efc2bd;
}

.danger-action:hover {
  background: var(--danger-bg);
  border-color: #e4a7a0;
}

.tour-overlay {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: rgba(8, 16, 34, 0.62);
}

.tour-highlight {
  position: relative;
  z-index: 35;
  border-radius: 8px;
  box-shadow: 0 0 0 4px rgba(39, 180, 255, 0.72), 0 14px 38px rgba(15, 23, 42, 0.22);
}

.tour-card {
  position: fixed;
  z-index: 40;
  display: grid;
  gap: 8px;
  padding: 14px;
  border: 1px solid rgba(39, 180, 255, 0.36);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.tour-eyebrow {
  margin: 0;
  color: var(--brand);
  font-size: 12px;
  font-weight: 800;
}

.tour-card h2 {
  margin: 0;
  font-size: 18px;
  line-height: 1.2;
}

.tour-card p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.tour-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 4px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(8, 16, 34, 0.58);
}

.donate-modal {
  position: relative;
  width: min(390px, 100%);
  display: grid;
  gap: 12px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.donate-modal h2 {
  margin: 0;
  padding-right: 40px;
  font-size: 20px;
  line-height: 1.2;
}

.donate-modal p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.donate-qr {
  width: min(220px, 100%);
  height: auto;
  justify-self: center;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
}

.toast {
  position: fixed;
  right: 16px;
  bottom: 16px;
  max-width: min(360px, calc(100vw - 32px));
  padding: 12px 14px;
  border-radius: 8px;
  background: #111827;
  color: #fff;
  box-shadow: var(--shadow);
  transform: translateY(18px);
  opacity: 0;
  pointer-events: none;
  transition: transform 160ms ease, opacity 160ms ease;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

.cookie-banner {
  position: fixed;
  left: 16px;
  bottom: 16px;
  z-index: 20;
  width: min(520px, calc(100vw - 32px));
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow);
}

.cookie-banner h2 {
  margin: 0 0 4px;
  font-size: 15px;
  line-height: 1.2;
}

.cookie-banner p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.cookie-actions {
  display: flex;
  gap: 8px;
}

.loader {
  width: 34px;
  height: 34px;
  margin: 0 auto 16px;
  border: 4px solid var(--line);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin 900ms linear infinite;
}

.mark {
  width: 54px;
  height: 54px;
  margin: 0 auto 16px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #eef3ff;
  color: var(--brand);
  font-weight: 700;
}

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

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 900px) {
  .topbar-inner,
  .workspace {
    padding-left: 14px;
    padding-right: 14px;
  }

  .workspace {
    grid-template-columns: 1fr;
  }

  .editor-panel {
    position: static;
  }
}

@media (max-width: 620px) {
  .login-screen,
  .system-screen {
    align-items: start;
    padding: 24px 14px;
  }

  .login-container,
  .system-box,
  .editor-panel,
  .list-panel {
    padding: 14px;
  }

  .topbar {
    position: static;
  }

  .topbar-inner {
    min-height: auto;
    padding-top: 10px;
    padding-bottom: 10px;
    align-items: flex-start;
  }

  .brand {
    gap: 9px;
  }

  .top-actions {
    margin-left: auto;
  }

  .user-chip {
    max-width: 42vw;
  }

  .workspace {
    padding-top: 12px;
    gap: 12px;
  }

  .section-heading {
    align-items: flex-start;
  }

  .path-input {
    grid-template-columns: 1fr;
  }

  .path-input span {
    height: 34px;
    max-width: none;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .redirect-card {
    grid-template-columns: 1fr;
  }

  .redirect-meta {
    justify-content: flex-start;
  }

  .redirect-actions .text-button {
    flex: 1 1 calc(50% - 8px);
  }
}

@media (max-width: 420px) {
  .brand h1 {
    font-size: 16px;
  }

  .brand p {
    font-size: 12px;
  }

  .user-chip {
    display: none;
  }

  .donate-button span {
    display: none;
  }

  .donate-button {
    width: 36px;
    padding: 0;
    justify-content: center;
  }

  .cookie-banner {
    grid-template-columns: 1fr;
  }

  .cookie-actions {
    justify-content: flex-start;
  }

  .redirect-actions .text-button {
    flex-basis: 100%;
  }
}
