:root {
  --bg: #fffbf3;
  --surface: #ffffff;
  --surface-alt: #f3f1e9;
  --text: #1c2b33;
  --muted: #5b6b7a;
  --brand: #0f766e;
  --brand-dark: #0b5b55;
  --accent: #d97706;
  --border: #e8ddc7;
  --danger: #b3261e;
  --success: #2e7d5b;
  --shadow: 0 12px 32px rgba(28, 43, 51, 0.08);
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 22px;
  --focus-ring: 0 0 0 3px rgba(15, 118, 110, 0.25);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.55;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar,
.container {
  max-width: 1080px;
  margin: 0 auto;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  width: 100%;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
}

.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: var(--brand);
  color: #fff;
  font-weight: 800;
}

.topnav {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.topnav a {
  color: var(--text);
  text-decoration: none;
  padding: 8px 12px;
  border-radius: 10px;
  font-weight: 500;
}

.topnav a:hover {
  background: var(--surface-alt);
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
  border-radius: var(--radius-sm);
}

.container {
  padding: 28px 24px 48px;
  width: 100%;
  flex: 1;
}

.loading {
  color: var(--muted);
  text-align: center;
  padding: 48px 0;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

a.card:hover {
  transform: translateY(-1px);
  box-shadow: 0 16px 40px rgba(28, 43, 51, 0.12);
}

.card + .card {
  margin-top: 16px;
}

h1,
h2,
h3 {
  line-height: 1.2;
}

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

.row {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

label {
  font-weight: 600;
  font-size: 14px;
}

input,
select,
textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font: inherit;
  background: var(--surface);
  color: var(--text);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--brand);
  box-shadow: var(--focus-ring);
}

textarea {
  min-height: 100px;
  resize: vertical;
}

button,
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 20px;
  border: 0;
  border-radius: var(--radius-md);
  background: var(--brand);
  color: #fff;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s ease, transform 0.1s ease;
}

button:hover,
.button:hover {
  background: var(--brand-dark);
  transform: translateY(-1px);
}

button:active,
.button:active {
  transform: translateY(0);
}

button.secondary,
.button.secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}

button.secondary:hover,
.button.secondary:hover {
  background: var(--surface-alt);
}

button.danger {
  background: var(--danger);
}

.pill {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  background: var(--surface-alt);
  color: var(--muted);
}

.pill.open {
  background: #e0f2ec;
  color: var(--brand-dark);
}

.pill.matched {
  background: #e8ecf3;
  color: #34445c;
}

.error {
  color: var(--danger);
  font-size: 14px;
}

.success {
  color: var(--brand);
  font-size: 14px;
}

.empty {
  color: var(--muted);
  text-align: center;
  padding: 32px 0;
}

.footer {
  border-top: 1px solid var(--border);
  padding: 20px 24px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
}

.footer-links {
  margin: 6px 0 0;
}

.footer-links a {
  color: var(--muted);
  text-decoration: none;
}

.footer-links a:hover {
  color: var(--brand-dark);
  text-decoration: underline;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  background: var(--text);
  color: #fff;
  padding: 12px 20px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 600;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 100;
}

.toast.toast-error {
  opacity: 1;
}

.toast.toast-success {
  opacity: 1;
  background: var(--brand);
}

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

@media (max-width: 560px) {
  .topbar {
    padding: 12px 16px;
  }

  .container {
    padding: 20px 16px 36px;
  }
}
