:root {
  --bg: #f4f1ea;
  --surface: #fffdf8;
  --surface-alt: #ece7dc;
  --text: #24262b;
  --muted: #5c5f66;
  --border: #d6cfc0;
  --accent: #1f5f5b;
  --accent-text: #ffffff;
  --selected: #dcebe7;
  --danger: #a4262c;
  --focus: #b3470d;
  --radius: 10px;
}

.dark {
  --bg: #16191d;
  --surface: #20242a;
  --surface-alt: #2c3138;
  --text: #edeae3;
  --muted: #a9adb3;
  --border: #3a4048;
  --accent: #7fd1c7;
  --accent-text: #10211f;
  --selected: #1f3a38;
  --danger: #ff9d9d;
  --focus: #ffc266;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

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

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

h2 {
  margin-bottom: 1rem;
  font-size: 1.15rem;
}

/* Header and footer */
.site-header {
  background: var(--accent);
  color: var(--accent-text);
}

.site-header__inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1.5rem;
  max-width: 1200px;
  margin: 0 auto;
  padding: 1rem 1.25rem;
}

.brand {
  font-size: 1.5rem;
  letter-spacing: -0.01em;
}

.site-header__tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1.25rem;
}

.user-switcher {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.user-switcher select {
  width: auto;
  padding: 0.35rem 0.5rem;
}

/* Menu bar */
.menu-bar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.menu-bar__list {
  display: flex;
  gap: 0.25rem;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1.25rem;
  list-style: none;
}

.menu-bar__link {
  display: block;
  padding: 0.75rem 1rem;
  color: var(--text);
  border-bottom: 3px solid transparent;
  font-weight: 600;
  text-decoration: none;
}

.menu-bar__link:hover {
  background: var(--surface-alt);
}

.menu-bar__link[aria-current="page"] {
  border-bottom-color: var(--accent);
  color: var(--accent);
}

.site-footer {
  margin-top: auto;
  padding: 1rem 1.25rem;
  color: var(--muted);
  font-size: 0.875rem;
  text-align: center;
}

/* Two-panel layout */
.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  grid-template-areas:
    "create create"
    "list detail";
  gap: 1.25rem;
  align-items: start;
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.25rem;
}

.create-card {
  grid-area: create;
}

.list-panel {
  grid-area: list;
}

.detail-panel {
  grid-area: detail;
}

.card {
  padding: 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

/* Forms */
.todo-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.875rem;
}

.todo-form--create {
  grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-width: 0;
}

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

label {
  font-size: 0.875rem;
  font-weight: 600;
}

input,
select,
textarea {
  width: 100%;
  padding: 0.55rem 0.7rem;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--muted);
  border-radius: 6px;
  font: inherit;
}

textarea {
  resize: vertical;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.625rem;
  grid-column: 1 / -1;
}

.button {
  justify-self: start;
  padding: 0.55rem 1rem;
  background: var(--surface-alt);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

a.button {
  display: inline-block;
  text-decoration: none;
}

.checkbox-field {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.checkbox-field input {
  width: auto;
}

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

.button--small {
  padding: 0.3rem 0.7rem;
  font-size: 0.875rem;
}

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

.button--on-accent {
  background: transparent;
  color: var(--accent-text);
  border-color: var(--accent-text);
}

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

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

/* Programmatic focus on these moves the reader, so it needs no ring. */
main:focus,
h2:focus {
  outline: none;
}

::placeholder {
  color: var(--muted);
  opacity: 1;
}

.field-hint {
  color: var(--muted);
  font-size: 0.8rem;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  top: 0.5rem;
  left: 0.5rem;
  z-index: 10;
  padding: 0.5rem 0.875rem;
  background: var(--surface);
  color: var(--text);
  border-radius: 6px;
  font-weight: 600;
  transform: translateY(-200%);
}

.skip-link:focus {
  transform: none;
}

html {
  scroll-behavior: smooth;
}

.button {
  transition: background-color 0.15s ease, color 0.15s ease;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  * {
    transition: none !important;
    animation: none !important;
  }
}

.notice {
  grid-area: notice;
  padding: 0.625rem 0.875rem;
  background: var(--surface-alt);
  border-left: 4px solid var(--accent);
  border-radius: 6px;
}

.layout:has(> .notice:not([hidden])) {
  grid-template-areas:
    "notice notice"
    "create create"
    "list detail";
}

/* Image field and camera */
.image-field__controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.25rem;
}

.image-field__preview {
  max-width: 220px;
  max-height: 160px;
  margin-top: 0.5rem;
  border-radius: 6px;
  object-fit: cover;
}

.image-field__current {
  max-width: 220px;
  max-height: 160px;
  margin-top: 0.5rem;
  border-radius: 6px;
  object-fit: cover;
}

.camera-dialog {
  width: min(92vw, 560px);
  padding: 1.25rem;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.camera-dialog::backdrop {
  background: rgb(0 0 0 / 60%);
}

.camera-dialog video {
  display: block;
  width: 100%;
  margin-bottom: 0.875rem;
  background: #000;
  border-radius: 6px;
}

/* Todo list */
.todo-list {
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.todo-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 0.875rem;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.todo-item--selected {
  background: var(--selected);
  border-color: var(--accent);
}

.todo-item__body {
  flex: 1;
  min-width: 0;
}

.todo-item__toggle {
  display: flex;
  flex-shrink: 0;
}

.todo-item__check {
  flex-shrink: 0;
  width: 1.15rem;
  height: 1.15rem;
  accent-color: var(--accent);
}

.todo-item__image {
  flex-shrink: 0;
  width: 3rem;
  height: 3rem;
  border-radius: 6px;
  object-fit: cover;
}

.todo-item__actions {
  display: flex;
  flex-shrink: 0;
  gap: 0.375rem;
}

.todo-item--done .todo-item__title {
  text-decoration: line-through;
}

.todo-item--done .todo-item__title,
.todo-item--done .todo-item__description {
  color: var(--muted);
}

.todo-item__title {
  font-size: 1rem;
  overflow-wrap: anywhere;
}

.todo-item__description {
  font-size: 0.9rem;
  overflow-wrap: anywhere;
}

.todo-item__meta {
  color: var(--muted);
  font-size: 0.875rem;
}

/* Panels stack on mobile */
@media (max-width: 767px) {
  .layout {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "create"
      "list"
      "detail";
    padding: 0.875rem;
  }

  .layout:has(> .notice:not([hidden])) {
    grid-template-areas:
      "notice"
      "create"
      "list"
      "detail";
  }

  .todo-form,
  .todo-form--create {
    grid-template-columns: minmax(0, 1fr);
  }

  .todo-item {
    flex-wrap: wrap;
  }

  .todo-item__body {
    flex-basis: calc(100% - 2.5rem);
  }

  .todo-item__actions {
    margin-left: 1.9rem;
  }
}
