:root {
  --bg0: #f3f6f2;
  --bg1: #e7eee8;
  --surface: rgba(255, 255, 255, 0.82);
  --surface-solid: #ffffff;
  --ink: #15241c;
  --muted: #5d7266;
  --line: rgba(21, 36, 28, 0.1);
  --accent: #2f6b4f;
  --accent-soft: #d9ebe1;
  --danger: #b53a2e;
  --danger-soft: #f7e4e1;
  --shadow: 0 10px 30px rgba(21, 36, 28, 0.08);
  --radius: 22px;
  --nav-h: 92px;
  --top-h: 96px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --touch: 64px;
  --font: "Outfit", system-ui, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 8%, #ffffff 0%, transparent 42%),
    radial-gradient(circle at 88% 0%, #dce8df 0%, transparent 38%),
    linear-gradient(165deg, var(--bg0), var(--bg1));
}

body {
  touch-action: manipulation;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
  border: 0;
  background: none;
  color: inherit;
}

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

#app {
  height: 100dvh;
  height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  max-width: 1200px;
  margin: 0 auto;
  position: relative;
}

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  padding: calc(18px + var(--safe-t)) 22px 14px;
  min-height: var(--top-h);
}

.eyebrow {
  margin: 0 0 4px;
  font-size: 0.95rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
}

.topbar h1 {
  margin: 0;
  font-size: clamp(2rem, 5vw, 2.6rem);
  line-height: 1;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.content {
  overflow: auto;
  padding: 8px 16px calc(18px + var(--safe-b));
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}

.bottom-nav {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  min-height: calc(var(--nav-h) + var(--safe-b));
  padding: 10px 14px calc(12px + var(--safe-b));
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
  box-shadow: 0 -8px 28px rgba(21, 36, 28, 0.06);
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 72px;
  border-radius: 18px;
  color: var(--muted);
  font-size: 0.95rem;
  font-weight: 600;
  transition: background 0.2s ease, color 0.2s ease, transform 0.15s ease;
}

.nav-item svg {
  width: 28px;
  height: 28px;
}

.nav-item.active {
  background: var(--accent-soft);
  color: var(--accent);
}

.nav-item:active {
  transform: scale(0.97);
}

.toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.search {
  flex: 1;
  min-width: 180px;
  min-height: var(--touch);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 0 18px;
  background: var(--surface-solid);
  font-size: 1.15rem;
  outline: none;
}

.search:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(47, 107, 79, 0.15);
}

.chip-row {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 4px;
  margin-bottom: 14px;
  scrollbar-width: none;
}

.chip-row::-webkit-scrollbar {
  display: none;
}

.chip {
  flex: 0 0 auto;
  min-height: 48px;
  padding: 0 18px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface-solid);
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
}

.chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

@media (min-width: 760px) and (orientation: landscape) {
  .grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .grid.dense {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (min-width: 1100px) and (orientation: landscape) {
  .grid.dense {
    grid-template-columns: repeat(4, 1fr);
  }
}

.card-item {
  display: grid;
  grid-template-columns: 84px 1fr auto;
  gap: 14px;
  align-items: center;
  min-height: 104px;
  padding: 14px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  text-align: left;
  width: 100%;
  transition: transform 0.15s ease, background 0.2s ease;
}

.lista-card {
  grid-template-columns: 84px 1fr;
  touch-action: pan-y;
  user-select: none;
  -webkit-user-select: none;
  will-change: transform;
  position: relative;
  z-index: 2;
  background: var(--surface-solid);
}

.lista-card:active {
  transform: none;
}

.swipe-row {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  min-height: 104px;
  background: #dfe6e1;
}

.swipe-action {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 22px;
  font-size: 1.15rem;
  font-weight: 700;
  color: #fff;
  opacity: 0;
  transition: opacity 0.15s ease;
  z-index: 1;
}

.swipe-action svg {
  width: 28px;
  height: 28px;
}

.swipe-action-left {
  justify-content: flex-start;
  background: var(--danger);
}

.swipe-action-right {
  justify-content: flex-end;
  background: var(--accent);
}

.swipe-row.reveal-left .swipe-action-left,
.swipe-row.reveal-right .swipe-action-right {
  opacity: 1;
}

.hint {
  text-align: center;
  color: var(--muted);
  margin: 18px 8px 0;
  font-size: 1.05rem;
}

.card-item.article-card {
  grid-template-columns: 84px 1fr;
  grid-template-areas:
    "thumb meta"
    "actions actions";
}

.card-item.article-card .thumb {
  grid-area: thumb;
}

.card-item.article-card .meta {
  grid-area: meta;
}

.card-item.article-card .card-actions {
  grid-area: actions;
  display: flex;
  gap: 10px;
  margin-top: 4px;
}

.card-item.article-card .card-actions .btn {
  flex: 1;
  min-height: 56px;
  font-size: 1.05rem;
}

.card-item:active {
  transform: scale(0.985);
}

.card-item.in-list {
  background: #edf6f1;
  border-color: rgba(47, 107, 79, 0.28);
}

.thumb {
  width: 84px;
  height: 84px;
  border-radius: 18px;
  object-fit: cover;
  background: #e8eee9;
}

.meta h3 {
  margin: 0 0 6px;
  font-size: 1.35rem;
  line-height: 1.15;
  letter-spacing: -0.02em;
}

.meta p {
  margin: 0;
  color: var(--muted);
  font-size: 1rem;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.tag {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 4px 10px;
  border-radius: 999px;
}

.action-badge {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  color: var(--accent);
  flex-shrink: 0;
}

.action-badge svg {
  width: 28px;
  height: 28px;
}

.action-badge.check {
  background: var(--accent);
  color: #fff;
}

.action-badge.warn {
  background: var(--danger-soft);
  color: var(--danger);
}

.empty {
  display: grid;
  place-items: center;
  text-align: center;
  min-height: 40vh;
  color: var(--muted);
  gap: 8px;
  padding: 24px;
}

.empty strong {
  color: var(--ink);
  font-size: 1.4rem;
}

.date-group {
  margin-bottom: 22px;
}

.date-group h2 {
  margin: 0 0 12px;
  font-size: 1.1rem;
  color: var(--muted);
  text-transform: capitalize;
  letter-spacing: 0.02em;
}

.icon-btn {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  background: var(--surface-solid);
  border: 1px solid var(--line);
  color: var(--ink);
}

.icon-btn svg {
  width: 26px;
  height: 26px;
}

.icon-btn.accent {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.btn {
  min-height: var(--touch);
  padding: 0 22px;
  border-radius: 18px;
  font-size: 1.15rem;
  font-weight: 650;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-secondary {
  background: var(--surface-solid);
  border: 1px solid var(--line);
  color: var(--ink);
}

.btn-danger {
  background: var(--danger-soft);
  color: var(--danger);
}

.btn svg {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
}

.btn:active:not(:disabled) {
  transform: scale(0.98);
}

.btn:disabled {
  opacity: 0.55;
  cursor: default;
}

.fab-row {
  display: flex;
  gap: 10px;
  margin-bottom: 14px;
}

.fab-row .btn {
  flex: 1;
}

.modal {
  border: 0;
  padding: 0;
  background: transparent;
  max-width: 100%;
  width: min(560px, 100%);
  margin: auto auto 0;
}

.modal::backdrop {
  background: rgba(16, 28, 22, 0.45);
  backdrop-filter: blur(4px);
}

.modal-sheet {
  background: var(--surface-solid);
  border-radius: 28px 28px 0 0;
  padding: 18px 18px calc(18px + var(--safe-b));
  box-shadow: 0 -20px 50px rgba(0, 0, 0, 0.18);
  max-height: min(88dvh, 900px);
  display: flex;
  flex-direction: column;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.modal-header h2 {
  margin: 0;
  font-size: 1.6rem;
  letter-spacing: -0.02em;
}

.modal-body {
  overflow: auto;
  display: grid;
  gap: 14px;
  padding-bottom: 8px;
}

.modal-footer {
  display: flex;
  gap: 10px;
  padding-top: 12px;
}

.modal-footer .btn {
  flex: 1;
}

.field {
  display: grid;
  gap: 8px;
}

.field label {
  font-weight: 600;
  font-size: 1.05rem;
}

.field input,
.field textarea {
  min-height: var(--touch);
  border-radius: 16px;
  border: 1px solid var(--line);
  padding: 0 16px;
  font-size: 1.15rem;
  background: #f7faf7;
  outline: none;
}

.field input:focus,
.field textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(47, 107, 79, 0.15);
}

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

.check-pill {
  min-height: 56px;
  border-radius: 16px;
  border: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 14px;
  font-weight: 600;
  background: #f7faf7;
}

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

.photo-preview {
  width: 100%;
  height: 160px;
  object-fit: cover;
  border-radius: 18px;
  background: #e8eee9;
  border: 1px solid var(--line);
}

.file-btn {
  position: relative;
  overflow: hidden;
}

.file-btn input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.photo-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.photo-actions .btn {
  flex: 1;
  min-width: 140px;
}

.img-search-query {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 1.05rem;
}

.img-search-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  overflow: auto;
  max-height: min(55dvh, 520px);
  padding-bottom: 4px;
}

@media (min-width: 760px) {
  .img-search-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

.img-search-option {
  position: relative;
  border: 0;
  padding: 0;
  border-radius: 18px;
  overflow: hidden;
  aspect-ratio: 1;
  background: #e8eee9;
  box-shadow: var(--shadow);
}

.img-search-option img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.img-search-option span {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 8px 10px;
  background: linear-gradient(transparent, rgba(16, 28, 22, 0.75));
  color: #fff;
  font-size: 0.85rem;
  font-weight: 600;
  text-align: left;
}

.img-search-option:active {
  transform: scale(0.98);
}

.img-search-option.loading {
  opacity: 0.55;
  pointer-events: none;
}

.img-search-note {
  margin: 14px 0 0;
  font-size: 0.9rem;
  color: var(--muted);
}

.img-search-empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 28px 12px;
  color: var(--muted);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--nav-h) + 18px + var(--safe-b));
  transform: translateX(-50%);
  background: var(--ink);
  color: #fff;
  padding: 14px 20px;
  border-radius: 16px;
  font-size: 1.05rem;
  font-weight: 600;
  z-index: 50;
  max-width: min(92vw, 420px);
  text-align: center;
  box-shadow: var(--shadow);
}

.toast[hidden] {
  display: none;
}

.count-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  height: 34px;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  font-size: 1rem;
  margin-left: 8px;
  vertical-align: middle;
}

.manage-list {
  display: grid;
  gap: 10px;
}

.manage-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 14px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: #f7faf7;
  min-height: 72px;
}

.manage-row strong {
  font-size: 1.2rem;
}

.manage-row span {
  color: var(--muted);
  font-size: 0.95rem;
}

.small-actions {
  display: flex;
  gap: 8px;
}

.small-actions .icon-btn {
  width: 48px;
  height: 48px;
}
