:root {
  --paper: #f3f4f6;
  --ink: #1a1d21;
  --muted: #5e6770;
  --line: #d5d9de;
  --accent: #b8421a;
  --field: #ffffff;
  --done: #5e6770;
  --outside: #e4e7eb;
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  min-height: 100dvh;
  background: var(--outside);
  color: var(--ink);
  font: 16px/1.4 system-ui, sans-serif;
}

main {
  max-width: 32rem;
  min-height: 100dvh;
  margin: 0 auto;
  padding: 0 1rem calc(1.5rem + env(safe-area-inset-bottom));
  background: var(--paper);
}

button, input, textarea { font: inherit; color: inherit; }

button {
  cursor: pointer;
  appearance: none;
  touch-action: manipulation;
}

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

.bar {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  min-height: 3.25rem;
  margin: 0 -1rem;
  padding: calc(0.25rem + env(safe-area-inset-top)) 1rem 0.25rem;
  background: var(--paper);
}

h1 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 650;
  letter-spacing: 0.06em;
}

h2, label {
  display: block;
  margin: 0 0 0.45rem;
  color: var(--muted);
  font-size: 0.95rem;
  font-weight: 600;
}

.back {
  width: 2.75rem;
  height: 2.75rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-left: -0.4rem;
  color: var(--ink);
  text-decoration: none;
}

.back svg {
  width: 1.5rem;
  height: 1.5rem;
}

.composer {
  display: flex;
  gap: 0.5rem;
  margin: 0.25rem 0 0.75rem;
}

.composer input,
textarea,
.title {
  width: 100%;
  background: var(--field);
  border: 1px solid var(--line);
  border-radius: 6px;
}

.composer input,
textarea {
  padding: 0.7rem 0.75rem;
}

.composer input { min-width: 0; }

textarea { resize: vertical; }

.title {
  margin: 0.25rem 0 0.75rem;
  padding: 0.35rem 0;
  border-color: transparent;
  background: transparent;
  font-size: 1.5rem;
  font-weight: 650;
  border-radius: 0;
}

.plus {
  flex: 0 0 2.75rem;
  width: 2.75rem;
  height: 2.75rem;
  padding: 0;
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  font-size: 1.6rem;
  line-height: 1;
}

.plus.ghost {
  background: var(--field);
  color: var(--accent);
}

.meta {
  margin: 0.15rem 0;
  color: var(--ink);
}

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

section { margin-top: 1.35rem; }

.project-list, .tasks {
  list-style: none;
  margin: 0;
  padding: 0;
}

.project {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  padding: 0.85rem 0;
  border-top: 1px solid var(--line);
  color: inherit;
  text-decoration: none;
}

.project-thumb {
  width: 3.25rem;
  height: 3.25rem;
  flex: 0 0 3.25rem;
  object-fit: cover;
  border-radius: 6px;
  background: #e1e4e8;
}

.project-copy { min-width: 0; flex: 1; }

.project:last-child { border-bottom: 1px solid var(--line); }

.project:active { background: #e7eaee; }

.project-title {
  display: block;
  font-weight: 650;
}

.project-meta, .project-desc {
  display: block;
  margin-top: 0.15rem;
  color: var(--muted);
}

.project-desc {
  display: -webkit-box;
  overflow: hidden;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.status {
  margin: 0.5rem 0;
  color: var(--muted);
}

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

.images .plus {
  align-self: flex-start;
}

.film {
  display: flex;
  gap: 0.5rem;
  flex: 1;
  min-width: 0;
  overflow-x: auto;
  padding-bottom: 0.15rem;
  -webkit-overflow-scrolling: touch;
}

.thumb {
  flex: 0 0 5.5rem;
  width: 5.5rem;
  height: 5.5rem;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--field);
  overflow: hidden;
}

.thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.task {
  display: flex;
  align-items: center;
  gap: 0.15rem;
  min-height: 2.75rem;
  border-bottom: 1px solid var(--line);
}

.nudge {
  flex: 0 0 2.5rem;
  width: 2.5rem;
  height: 2.5rem;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--ink);
}

.nudge:disabled {
  color: #c5cad0;
  cursor: default;
}

.nudge svg {
  display: block;
  width: 1rem;
  height: 1rem;
  margin: 0 auto;
}

.task-field {
  position: relative;
  flex: 1;
  min-width: 0;
}

.task-text {
  width: 100%;
  padding: 0.45rem 0.2rem;
  border: none;
  background: transparent;
}

.task-rule {
  display: none;
  position: absolute;
  left: 0.2rem;
  top: 0;
  max-width: calc(100% - 0.4rem);
  overflow: hidden;
  white-space: pre;
  color: transparent;
  pointer-events: none;
  line-height: 2.75rem;
  text-decoration: line-through;
  text-decoration-color: var(--done);
  text-decoration-thickness: 1.5px;
}

.task.is-done .task-text { color: var(--done); }

.task.is-done .task-rule { display: block; }

.tick-wrap {
  flex: 0 0 2.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 2.75rem;
}

.tick {
  width: 1.35rem;
  height: 1.35rem;
  margin: 0;
  accent-color: var(--accent);
}

.sheet, .viewer {
  position: fixed;
  inset: 0;
  z-index: 5;
}

.sheet {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: env(safe-area-inset-bottom);
  background: rgba(26, 29, 33, 0.4);
}

.sheet[hidden], .viewer[hidden], main[hidden] { display: none; }

.sheet-card {
  width: min(32rem, 100%);
  padding: 12px 16px 16px;
  background: var(--field);
}

.sheet-card button {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 3rem;
  padding: 0 0.75rem;
  border: none;
  border-bottom: 1px solid var(--line);
  background: transparent;
  text-align: left;
}

.sheet-card button:last-child { border-bottom: none; color: var(--muted); }

.viewer {
  display: flex;
  flex-direction: column;
  background: var(--paper);
}

#viewer-frame {
  flex: 1;
  min-height: 0;
  background: #111;
}

#viewer-frame img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.viewer-actions {
  display: flex;
  gap: 0.5rem;
  padding: 0.75rem 1rem calc(0.75rem + env(safe-area-inset-bottom));
}

.viewer-actions button {
  flex: 1;
  min-height: 2.75rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--field);
}

#viewer-remove { color: var(--accent); border-color: var(--accent); }

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