:root {
  --bg: #f3f5ef;
  --card: #fffdf8;
  --ink: #1f2923;
  --muted: #55635a;
  --accent: #13795b;
  --accent-2: #dcefe8;
  --danger: #8f2d2d;
  --line: #c8d2cb;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Avenir Next", "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 10% 10%, #e6efe8 0%, transparent 38%),
    radial-gradient(circle at 90% 5%, #dbe8df 0%, transparent 30%),
    var(--bg);
}

.app-shell {
  max-width: 760px;
  margin: 2rem auto;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 1.25rem;
  box-shadow: 0 12px 36px rgba(21, 34, 28, 0.08);
}

.app-header h1 {
  margin: 0;
}

.app-header p {
  margin-top: 0.35rem;
  color: var(--muted);
}

.header-row {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 1rem;
}

.link-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.5rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  text-decoration: none;
  padding: 0 0.9rem;
}

.header-actions {
  display: grid;
  gap: 0.45rem;
  justify-items: end;
}

.header-buttons {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
  justify-content: end;
}

.auth-form {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
  justify-content: end;
}

.auth-form input {
  height: 2rem;
  min-width: 120px;
}

.auth-form button {
  height: 2rem;
  font-size: 0.8rem;
}

.auth-status {
  margin: 0;
  text-align: right;
  max-width: 420px;
}

.auth-shell {
  max-width: 520px;
}

.auth-panel {
  margin-top: 1rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1rem;
  background: #fcfdfb;
}

.standalone-auth-form {
  display: grid;
  gap: 0.7rem;
}

.standalone-auth-form input {
  width: 100%;
}

.auth-actions {
  display: flex;
  gap: 0.6rem;
}

.composer form {
  display: grid;
  grid-template-columns: 1fr 170px 170px auto;
  gap: 0.75rem;
  align-items: end;
}

.field {
  display: grid;
  gap: 0.4rem;
}

.field span {
  font-size: 0.85rem;
  color: var(--muted);
}

input,
select,
button {
  font: inherit;
}

input,
select {
  height: 2.5rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0 0.75rem;
}

button {
  height: 2.5rem;
  border: 1px solid var(--accent);
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  padding: 0 0.9rem;
  cursor: pointer;
}

.secondary {
  border-color: var(--line);
  background: #fff;
  color: var(--ink);
}

.toolbar {
  margin-top: 1rem;
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 1rem;
}

.toolbar-controls {
  display: flex;
  gap: 0.75rem;
}

.toolbar p {
  margin: 0;
  color: var(--muted);
}

.category-manager {
  margin-top: 1rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.8rem;
  background: #fcfdfb;
}

.settings-grid {
  margin-top: 0.75rem;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.8rem;
}

.capture-panel {
  margin-top: 1rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.8rem;
  background: #f8fbf9;
}

.capture-panel h2 {
  margin: 0;
  font-size: 1rem;
}

.capture-form {
  margin-top: 0.55rem;
  display: grid;
  grid-template-columns: 140px 1fr 1.8fr auto;
  gap: 0.6rem;
  align-items: end;
}

.capture-message textarea {
  border: 1px solid var(--line);
  border-radius: 10px;
  min-height: 2.5rem;
  resize: vertical;
  font: inherit;
  padding: 0.6rem 0.75rem;
}

#capture-list {
  list-style: none;
  margin: 0.7rem 0 0;
  padding: 0;
  display: grid;
  gap: 0.5rem;
}

.capture-row {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  padding: 0.55rem 0.65rem;
  display: flex;
  justify-content: space-between;
  gap: 0.7rem;
}

.capture-meta,
.capture-text {
  margin: 0;
}

.capture-meta {
  font-size: 0.9rem;
  color: var(--muted);
  display: flex;
  gap: 0.45rem;
}

.capture-text {
  margin-top: 0.35rem;
}

.capture-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
}

.capture-actions button {
  height: 2rem;
  font-size: 0.85rem;
}

.capture-triage {
  display: grid;
  grid-template-columns: 1.4fr 0.8fr 0.8fr;
  gap: 0.45rem;
  width: 100%;
}

.capture-triage input,
.capture-triage select {
  height: 2rem;
  font-size: 0.85rem;
}

.category-manager.standalone {
  margin-top: 0.75rem;
}

.category-manager h2 {
  margin: 0 0 0.5rem;
  font-size: 1rem;
}

#category-form {
  display: flex;
  gap: 0.6rem;
  align-items: end;
}

#category-form .field {
  flex: 1;
}

#sender-form {
  display: flex;
  gap: 0.6rem;
  align-items: end;
}

#sender-form .field {
  flex: 1;
}

#category-list {
  list-style: none;
  margin: 0.65rem 0 0;
  padding: 0;
  display: grid;
  gap: 0.45rem;
}

#category-list li {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  padding: 0.45rem 0.6rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}

#sender-list {
  list-style: none;
  margin: 0.65rem 0 0;
  padding: 0;
  display: grid;
  gap: 0.45rem;
}

#sender-list li {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  padding: 0.45rem 0.6rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}

.sender-edit-form {
  width: 100%;
  display: flex;
  gap: 0.6rem;
  align-items: end;
}

.sender-edit-form .field {
  flex: 1;
}

.category-actions {
  display: flex;
  gap: 0.35rem;
}

.category-actions button {
  height: 1.8rem;
  font-size: 0.8rem;
}

.muted {
  color: var(--muted);
  font-size: 0.85rem;
}

.list-panel {
  margin-top: 1rem;
}

#todo-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 0.6rem;
}

.todo-row {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.8rem;
  background: #fff;
  display: flex;
  justify-content: space-between;
  gap: 0.8rem;
}

.todo-row.is-done {
  background: var(--accent-2);
}

.todo-row.is-editing {
  background: #f8fbf9;
}

.todo-title {
  margin: 0;
  font-weight: 600;
}

.todo-row.is-done .todo-title {
  text-decoration: line-through;
  color: var(--muted);
}

.todo-meta {
  margin: 0.45rem 0 0;
  display: flex;
  gap: 0.45rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.chip {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.1rem 0.5rem;
  background: #f9fbf8;
  text-transform: capitalize;
}

.todo-actions {
  display: flex;
  gap: 0.4rem;
  align-items: center;
}

.todo-actions button {
  height: 2rem;
  font-size: 0.85rem;
}

.todo-actions .danger {
  border-color: var(--danger);
  background: #fff;
  color: var(--danger);
}

.todo-actions .secondary {
  border-color: var(--line);
}

.todo-edit-form {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr 170px 170px auto;
  gap: 0.6rem;
  align-items: end;
}

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

@media (max-width: 720px) {
  .app-shell {
    margin: 1rem;
  }

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

  .header-actions {
    justify-items: stretch;
  }

  .auth-form {
    justify-content: stretch;
  }

  .auth-form input,
  .auth-form button {
    width: 100%;
  }

  .auth-status {
    text-align: left;
  }

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

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

  .capture-row {
    flex-direction: column;
  }

  .capture-triage {
    grid-template-columns: 1fr;
  }

  .toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .toolbar-controls {
    flex-direction: column;
  }

  #category-form {
    flex-direction: column;
    align-items: stretch;
  }

  #sender-form {
    flex-direction: column;
    align-items: stretch;
  }

  .sender-edit-form {
    flex-direction: column;
    align-items: stretch;
  }

  #category-list li {
    flex-wrap: wrap;
  }

  #sender-list li {
    flex-wrap: wrap;
  }

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

  .todo-row {
    flex-direction: column;
  }

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