:root {
  color-scheme: light;
  --bg: #f8f7f2;
  --panel: #ffffff;
  --ink: #18211d;
  --muted: #69736e;
  --line: #ddd9cf;
  --soft: #efede6;
  --accent: #0f766e;
  --accent-dark: #0d5f59;
  --danger: #a33a2b;
  --shadow: 0 20px 45px rgba(35, 38, 32, 0.08);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--bg);
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.topbar,
.capture-form,
.filters,
.list-shell,
.editor {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 18px 20px;
  box-shadow: var(--shadow);
}

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

h1 {
  font-size: 1.55rem;
  line-height: 1.1;
}

h2 {
  font-size: 1rem;
}

p,
label,
#result-count,
.item-meta {
  color: var(--muted);
}

label,
#result-count {
  font-size: 0.9rem;
}

.data-menu {
  position: relative;
}

.data-menu summary {
  min-width: 74px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  list-style: none;
  text-align: center;
  color: var(--muted);
}

.data-menu summary::-webkit-details-marker {
  display: none;
}

.data-actions {
  position: absolute;
  right: 0;
  z-index: 3;
  display: grid;
  gap: 8px;
  min-width: 150px;
  margin-top: 8px;
  padding: 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.data-actions button,
.data-actions label {
  min-height: 38px;
  padding: 9px 10px;
  color: var(--ink);
  background: var(--soft);
  border: 0;
  border-radius: 8px;
  text-align: center;
}

.data-actions input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.capture-form {
  display: grid;
  gap: 12px;
  margin-top: 18px;
  padding: 18px;
}

textarea,
input[type="search"],
input[type="date"],
input[type="text"] {
  width: 100%;
  color: var(--ink);
  background: #fbfaf7;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: none;
}

textarea {
  min-height: 128px;
  padding: 14px;
  resize: vertical;
  line-height: 1.45;
}

input[type="search"],
input[type="date"],
input[type="text"] {
  min-height: 42px;
  padding: 0 12px;
}

textarea:focus,
input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.13);
}

.capture-row,
.filters,
.list-head,
.item-card,
.item-actions,
.editor-head,
.editor-actions {
  display: flex;
  align-items: center;
}

.capture-row {
  justify-content: space-between;
  gap: 14px;
}

.today-check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
}

.today-check input {
  width: 17px;
  height: 17px;
  accent-color: var(--accent);
}

button,
.primary-action,
.danger-action,
.text-action {
  min-height: 40px;
  padding: 0 14px;
  color: var(--ink);
  background: var(--soft);
  border: 1px solid transparent;
  border-radius: 8px;
}

.primary-action {
  color: #fff;
  background: var(--accent);
  font-weight: 700;
}

.primary-action:hover {
  background: var(--accent-dark);
}

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

.filters {
  justify-content: space-between;
  gap: 12px;
  margin-top: 14px;
  padding: 12px;
}

.tabs {
  display: flex;
  gap: 6px;
}

.tab {
  color: var(--muted);
  background: transparent;
}

.tab.active {
  color: var(--ink);
  background: var(--soft);
}

.tab span {
  margin-left: 5px;
}

.filters input {
  max-width: 260px;
}

.list-shell {
  margin-top: 14px;
  padding: 16px;
}

.list-head {
  justify-content: space-between;
  gap: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.items-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.item-card {
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdfa;
}

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

.item-card.done {
  opacity: 0.62;
}

.item-main {
  display: grid;
  flex: 1;
  min-width: 0;
  gap: 5px;
  padding: 0;
  background: transparent;
  text-align: left;
}

.item-text {
  overflow-wrap: anywhere;
  line-height: 1.35;
}

.item-meta {
  font-size: 0.84rem;
}

.item-actions {
  gap: 6px;
}

.item-actions button {
  min-height: 34px;
  padding: 0 10px;
  font-size: 0.86rem;
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 220px;
  padding: 24px;
  text-align: center;
}

.empty-state h3 {
  margin-bottom: 6px;
}

.editor {
  margin-top: 14px;
  padding: 18px;
}

.editor form {
  display: grid;
  gap: 12px;
}

.editor-head,
.editor-actions {
  justify-content: space-between;
  gap: 10px;
}

.text-action {
  background: transparent;
  color: var(--muted);
}

.editor-grid {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 10px;
}

.editor-actions {
  justify-content: flex-start;
  flex-wrap: wrap;
}

@media (max-width: 680px) {
  .app {
    width: min(100% - 20px, 860px);
    padding-top: 16px;
  }

  .topbar,
  .filters,
  .item-card,
  .capture-row {
    align-items: stretch;
    flex-direction: column;
  }

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

  .filters input {
    max-width: none;
  }

  .item-actions {
    justify-content: stretch;
  }

  .item-actions button,
  .primary-action {
    flex: 1;
  }

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