:root {
  color-scheme: light dark;
  --bg: #f7f4ef;
  --text: #16201b;
  --muted: #637067;
  --soft: #f7ead7;
  --surface: rgb(255 255 255 / 62%);
  --surface-strong: rgb(255 255 255 / 78%);
  --surface-hover: rgb(255 255 255 / 90%);
  --border: rgb(31 41 36 / 12%);
  --accent: #007c72;
  --accent-strong: #005f59;
  --accent-text: #ffffff;
  --warm: #d98946;
  --danger: #b4534a;
  --shadow: 0 24px 70px rgb(38 34 28 / 16%);
  --radius: 8px;
  --blur: 18px;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #111510;
  --text: #f2f4ef;
  --muted: #a9b2aa;
  --soft: #243225;
  --surface: rgb(17 23 18 / 62%);
  --surface-strong: rgb(24 32 25 / 82%);
  --surface-hover: rgb(35 47 36 / 88%);
  --border: rgb(237 243 235 / 14%);
  --accent: #76d6c8;
  --accent-strong: #9ee3d8;
  --accent-text: #081411;
  --warm: #f0b35f;
  --danger: #ff9a8f;
  --shadow: 0 24px 70px rgb(0 0 0 / 34%);
}

* {
  box-sizing: border-box;
}

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

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  font-family:
    Inter,
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
}

body::before {
  position: fixed;
  inset: 0;
  z-index: -2;
  background:
    linear-gradient(140deg, rgb(255 255 255 / 42%), rgb(255 255 255 / 0) 42%),
    linear-gradient(45deg, rgb(0 124 114 / 15%), rgb(217 137 70 / 16%));
  content: "";
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.wallpaper {
  position: fixed;
  inset: 0;
  z-index: -3;
  background:
    image-set(url("./assets/wallpaper.svg") type("image/svg+xml")),
    linear-gradient(135deg, #f5dcc1, #d5eee9 54%, #e7e4ff);
  background-position: center;
  background-size: cover;
}

.app-shell {
  width: min(1220px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 56px;
}

.glass-panel {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  backdrop-filter: blur(var(--blur)) saturate(135%);
}

.topbar {
  position: sticky;
  top: 16px;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 72px;
  padding: 14px 16px;
}

.brand,
.toolbar,
.category-button,
.site-link,
.site-meta,
.panel-header,
.quick-stats {
  display: flex;
  align-items: center;
}

.brand {
  min-width: 0;
  gap: 12px;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 8px;
  background: var(--accent);
  color: var(--accent-text);
  font-weight: 800;
}

.brand-title,
.brand-subtitle,
.card-title,
.card-url {
  display: block;
}

.brand-title {
  font-weight: 800;
}

.brand-subtitle,
.card-url,
.summary,
.stat-label,
.group-count,
.admin-panel p {
  color: var(--muted);
}

.brand-subtitle,
.card-url,
.stat-label,
.group-count {
  font-size: 0.86rem;
}

.toolbar {
  gap: 10px;
}

.icon-button {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-strong);
  color: var(--text);
}

.hero {
  display: grid;
  grid-template-columns: 1fr minmax(320px, 440px);
  gap: 28px;
  margin-top: 24px;
  padding: 32px;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--accent-strong);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 16px;
  font-size: clamp(2.45rem, 7vw, 5.8rem);
  line-height: 0.95;
}

h2 {
  margin-bottom: 0;
  font-size: 1.08rem;
}

h3 {
  margin-bottom: 0;
  font-size: 1rem;
}

.summary {
  max-width: 680px;
  margin-bottom: 0;
  font-size: 1.06rem;
  line-height: 1.75;
}

.search-form {
  align-self: end;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
}

.search-form input,
.search-form button,
.admin-form input,
.admin-form select,
.admin-form button {
  min-height: 48px;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.search-form input,
.admin-form input,
.admin-form select {
  min-width: 0;
  padding: 0 16px;
  background: var(--surface-strong);
  color: var(--text);
}

.search-form button,
.admin-form button {
  padding: 0 20px;
  border-color: transparent;
  background: var(--accent);
  color: var(--accent-text);
  font-weight: 700;
}

.quick-stats {
  gap: 14px;
  margin-top: 18px;
}

.stat-card {
  min-width: 132px;
  padding: 16px;
}

.stat-value {
  display: block;
  font-size: 1.45rem;
  font-weight: 850;
}

.content-grid {
  display: grid;
  grid-template-columns: 230px minmax(0, 1fr);
  gap: 18px;
  margin-top: 18px;
}

.side-panel,
.bookmark-group,
.admin-panel {
  padding: 18px;
}

.side-panel {
  position: sticky;
  top: 106px;
  align-self: start;
}

.panel-header {
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

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

.category-button {
  justify-content: space-between;
  width: 100%;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  text-align: left;
}

.category-button.is-active,
.category-button:hover {
  border-color: var(--border);
  background: var(--surface-hover);
}

.bookmark-board {
  display: grid;
  gap: 18px;
}

.bookmark-group {
  background: var(--surface);
}

.group-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.site-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.site-card {
  position: relative;
  min-height: 104px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 10px;
  padding: 16px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-strong);
  transition:
    border-color 160ms ease,
    background-color 160ms ease,
    opacity 160ms ease,
    transform 160ms ease;
}

.site-card:hover {
  border-color: color-mix(in srgb, var(--accent) 44%, var(--border));
  background: var(--surface-hover);
  transform: translateY(-2px);
}

.site-card.is-dragging {
  opacity: 0.52;
}

.site-link {
  min-width: 0;
  align-items: flex-start;
  gap: 14px;
}

.drag-handle,
.card-action {
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgb(255 255 255 / 18%);
  color: var(--muted);
}

.drag-handle {
  width: 30px;
  height: 42px;
  cursor: grab;
}

.drag-handle:active {
  cursor: grabbing;
}

.site-icon {
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--soft);
}

.site-meta {
  min-width: 0;
  align-items: flex-start;
  flex-direction: column;
  gap: 6px;
}

.card-title {
  max-width: 100%;
  overflow: hidden;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-url {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag {
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.72rem;
}

.card-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.card-action {
  width: 30px;
  height: 30px;
}

.card-action:hover,
.drag-handle:hover,
.ghost-button:hover {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
  color: var(--text);
}

.admin-panel {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 20;
  width: min(360px, calc(100% - 36px));
  opacity: 0;
  pointer-events: none;
  transform: translateY(18px);
  transition:
    opacity 180ms ease,
    transform 180ms ease;
}

.admin-panel.is-open {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.admin-form,
.admin-form label {
  display: grid;
  gap: 10px;
}

.admin-form {
  gap: 14px;
}

.admin-form label {
  color: var(--muted);
  font-size: 0.86rem;
}

.form-actions {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
}

.ghost-button {
  min-height: 48px;
  padding: 0 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-strong);
  color: var(--text);
}

.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;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    color-scheme: dark;
    --bg: #111510;
    --text: #f2f4ef;
    --muted: #a9b2aa;
    --soft: #243225;
    --surface: rgb(17 23 18 / 62%);
    --surface-strong: rgb(24 32 25 / 82%);
    --surface-hover: rgb(35 47 36 / 88%);
    --border: rgb(237 243 235 / 14%);
    --accent: #76d6c8;
    --accent-strong: #9ee3d8;
    --accent-text: #081411;
    --warm: #f0b35f;
    --danger: #ff9a8f;
    --shadow: 0 24px 70px rgb(0 0 0 / 34%);
  }
}

@media (max-width: 960px) {
  .hero,
  .content-grid {
    grid-template-columns: 1fr;
  }

  .side-panel {
    position: static;
  }

  .category-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .site-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 620px) {
  .app-shell {
    width: min(100% - 22px, 560px);
    padding-top: 12px;
  }

  .topbar,
  .hero {
    padding: 16px;
  }

  .brand-subtitle {
    display: none;
  }

  .hero {
    gap: 20px;
  }

  .search-form {
    grid-template-columns: 1fr;
  }

  .quick-stats,
  .category-list {
    grid-template-columns: 1fr;
  }

  .quick-stats {
    display: grid;
  }

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

  .site-card {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .drag-handle {
    display: none;
  }
}
