:root {
  color-scheme: light;
  --bg: #f7f7f4;
  --surface: #ffffff;
  --surface-soft: #eff7f5;
  --text: #17201f;
  --muted: #687270;
  --border: #dbe3e1;
  --accent: #0f766e;
  --accent-strong: #0b5f59;
  --accent-text: #0f766e;
  --danger-soft: #fff1f0;
  --danger-border: #f3d4d0;
  --notice-bg: #fff7d6;
  --notice-border: #eadb9a;
  --image-bg: #ecefed;
  --dialog-image-bg: #eef0ef;
  --favorite-bg: rgba(255, 255, 255, .92);
  --favorite-border: rgba(255, 255, 255, .75);
  --favorite-active: #a25b00;
  --dialog-backdrop: rgba(0, 0, 0, .55);
  --radius: 22px;
  --shadow: 0 12px 34px rgba(23, 32, 31, 0.08);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #101514;
  --surface: #171d1c;
  --surface-soft: #13201e;
  --text: #eef4f2;
  --muted: #a3afac;
  --border: #2c3936;
  --accent: #0f766e;
  --accent-strong: #14877d;
  --accent-text: #69cfc2;
  --danger-soft: #2a1718;
  --danger-border: #5b3032;
  --notice-bg: #2c2817;
  --notice-border: #5a5125;
  --image-bg: #202826;
  --dialog-image-bg: #202826;
  --favorite-bg: rgba(23, 29, 28, .94);
  --favorite-border: rgba(255, 255, 255, .16);
  --favorite-active: #f3b35c;
  --dialog-backdrop: rgba(0, 0, 0, .72);
  --shadow: 0 12px 34px rgba(0, 0, 0, .32);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  background: var(--bg);
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
}

button, input, select {
  font: inherit;
}

button, a {
  -webkit-tap-highlight-color: transparent;
}

img {
  display: block;
  max-width: 100%;
}

.shell {
  width: min(1120px, calc(100% - 32px));
  margin-inline: auto;
}

.app-header {
  padding: 28px 0 14px;
}

.header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

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

.theme-toggle {
  width: 44px;
  min-width: 44px;
  padding: 0;
  font-size: 22px;
  line-height: 1;
}

.theme-toggle span {
  display: block;
  transform: translateY(-1px);
}

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

h1 {
  margin-bottom: 4px;
  font-size: clamp(28px, 4vw, 44px);
  line-height: 1.05;
}

h2 {
  margin-bottom: 8px;
  font-size: clamp(22px, 3vw, 32px);
}

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

.eyebrow {
  margin-bottom: 6px;
  color: var(--accent-text);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .12em;
}

.button {
  min-height: 44px;
  border-radius: 14px;
  padding: 10px 16px;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.button-primary {
  background: var(--accent);
  color: white;
}

.button-primary:hover {
  background: var(--accent-strong);
}

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

.hero {
  margin: 18px 0 22px;
  padding: clamp(22px, 4vw, 38px);
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: 28px;
  display: grid;
  grid-template-columns: 1.25fr .75fr;
  gap: 24px;
  align-items: center;
}

.hero p {
  max-width: 680px;
  margin-bottom: 0;
  color: var(--muted);
}

.hero-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.hero-stats div {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 16px;
  min-width: 0;
}

.hero-stats strong {
  display: block;
  font-size: 22px;
}

.hero-stats span {
  display: block;
  font-size: 12px;
  color: var(--muted);
}

.toolbar {
  display: grid;
  grid-template-columns: 1fr 220px auto;
  gap: 10px;
  margin-bottom: 16px;
}

.toolbar input, .toolbar select {
  width: 100%;
  min-height: 46px;
  padding: 0 14px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
}

.notice {
  margin-bottom: 18px;
  padding: 12px 16px;
  background: var(--notice-bg);
  border: 1px solid var(--notice-border);
  border-radius: 14px;
}

.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin: 24px 0 12px;
}

.section-heading h2 {
  margin-bottom: 0;
}

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

.technique-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.card-open {
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.card-image-wrap {
  aspect-ratio: 4 / 3;
  background: var(--image-bg);
  overflow: hidden;
}

.card-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.card-body {
  padding: 16px;
}

.card-category {
  display: inline-block;
  margin-bottom: 7px;
  color: var(--accent-text);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .06em;
}

.card-title {
  margin-bottom: 8px;
  font-size: 20px;
  line-height: 1.2;
}

.card-summary {
  min-height: 48px;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 14px;
}

.card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  font-size: 12px;
  color: var(--muted);
}

.card-meta span {
  padding: 5px 8px;
  border-radius: 999px;
  background: var(--bg);
  border: 1px solid var(--border);
}

.favorite-control {
  position: absolute;
  z-index: 2;
  top: 10px;
  right: 10px;
  width: 44px;
  height: 44px;
  border: 1px solid var(--favorite-border);
  border-radius: 50%;
  background: var(--favorite-bg);
  color: var(--text);
  font-size: 24px;
  cursor: pointer;
}

.favorite-control.active {
  color: var(--favorite-active);
}

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

.project-note {
  margin: 36px 0 18px;
  padding: 24px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.project-note p {
  margin-bottom: 0;
  color: var(--muted);
  max-width: 720px;
}

.safety-note {
  margin: 18px 0 42px;
  padding: 18px;
  border-radius: 16px;
  background: var(--danger-soft);
  border: 1px solid var(--danger-border);
}

.technique-dialog {
  width: min(820px, calc(100% - 24px));
  max-height: calc(100% - 32px);
  padding: 0;
  border: 0;
  border-radius: 24px;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
}

.technique-dialog::backdrop {
  background: var(--dialog-backdrop);
}

.dialog-close {
  position: sticky;
  z-index: 3;
  top: 12px;
  float: right;
  margin: 12px;
  width: 44px;
  height: 44px;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--surface);
  color: var(--text);
  font-size: 26px;
  cursor: pointer;
}

.dialog-image {
  width: 100%;
  max-height: 520px;
  object-fit: contain;
  background: var(--dialog-image-bg);
}

.dialog-gallery {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  padding: 12px;
  background: var(--dialog-image-bg);
}

.dialog-gallery .dialog-image {
  width: 100%;
  max-height: none;
  object-fit: contain;
  border-radius: 14px;
  background: var(--dialog-image-bg);
}

.dialog-body {
  padding: 22px;
}

.dialog-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 18px 0;
}

.dialog-fact {
  padding: 12px;
  border-radius: 14px;
  background: var(--bg);
  border: 1px solid var(--border);
}

.dialog-fact small {
  display: block;
  color: var(--muted);
}

.dialog-warning {
  padding: 14px;
  border-radius: 14px;
  background: var(--danger-soft);
}

.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 (max-width: 850px) {
  .hero {
    grid-template-columns: 1fr;
  }

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

  .search-field {
    grid-column: 1 / -1;
  }

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

  .project-note {
    align-items: flex-start;
    flex-direction: column;
  }
}

@media (max-width: 560px) {
  .shell {
    width: min(100% - 20px, 1120px);
  }

  .app-header {
    padding-top: 18px;
  }

  .header-row {
    align-items: flex-start;
    flex-direction: column;
  }

  .hero {
    padding: 18px;
    border-radius: 20px;
  }

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

  .hero-stats div {
    padding: 10px;
  }

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

  .search-field {
    grid-column: auto;
  }

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

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