:root {
  color-scheme: light;
  --paper: #fbfdf8;
  --panel: #ffffff;
  --ink: #1f2a24;
  --muted: #657269;
  --line: #d9e2d6;
  --leaf: #2f7d55;
  --leaf-dark: #225f41;
  --tomato: #cf3f37;
  --tomato-dark: #a5302a;
  --corn: #f3c34a;
  --sky: #4f8fba;
  --shadow: 0 18px 45px rgba(31, 42, 36, 0.12);
  --radius: 8px;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--paper);
}

body {
  min-height: 100%;
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(47, 125, 85, 0.09), transparent 32%),
    linear-gradient(225deg, rgba(207, 63, 55, 0.08), transparent 34%),
    var(--paper);
}

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

button,
select,
input[type="submit"] {
  cursor: pointer;
}

button:disabled,
select:disabled,
input:disabled {
  cursor: not-allowed;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(79, 143, 186, 0.45);
  outline-offset: 2px;
}

.auth-gate {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  overflow-y: auto;
  background:
    linear-gradient(135deg, rgba(47, 125, 85, 0.14), transparent 38%),
    linear-gradient(225deg, rgba(207, 63, 55, 0.12), transparent 40%),
    rgba(251, 253, 248, 0.96);
  padding: 18px;
}

.auth-gate[hidden] {
  display: none;
}

.auth-panel {
  display: grid;
  gap: 14px;
  width: min(420px, 100%);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.94);
  padding: 20px;
  box-shadow: var(--shadow);
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.auth-brand p {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 850;
}

.auth-brand span,
.auth-message {
  color: var(--muted);
  font-size: 0.92rem;
}

.google-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: white;
  color: var(--ink);
  font-weight: 800;
}

.google-button[hidden],
.auth-divider[hidden] {
  display: none;
}

.google-button:hover {
  border-color: var(--sky);
}

.google-button[aria-disabled="true"] {
  border-color: #cfd9cc;
  background: #f8faf6;
  color: var(--muted);
  cursor: pointer;
}

.google-button[aria-disabled="true"]:hover {
  border-color: var(--leaf);
  color: var(--ink);
}

.google-button svg path {
  fill: currentColor;
  stroke: none;
}

.auth-divider {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 800;
  text-transform: uppercase;
}

.auth-divider::before,
.auth-divider::after {
  content: "";
  height: 1px;
  background: var(--line);
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: white;
}

.auth-tabs button {
  min-height: 40px;
  border: 0;
  border-right: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  font-weight: 800;
}

.auth-tabs button:last-child {
  border-right: 0;
}

.auth-tabs button[data-active="true"] {
  background: var(--ink);
  color: white;
}

.classic-auth-form {
  display: grid;
  gap: 8px;
}

.classic-auth-form .primary-button {
  width: 100%;
  margin-top: 4px;
}

.auth-message {
  min-height: 22px;
  margin: 0;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(260px, 300px) minmax(0, 1fr);
  min-height: 100vh;
}

.drawer-overlay {
  display: none;
}

.list-sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow-y: auto;
  border-right: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.88);
  padding: 22px;
  backdrop-filter: blur(18px);
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
}

.brand-lockup p {
  margin: 0;
  font-weight: 800;
}

.brand-lockup span,
.title-stack p,
.item-meta,
.list-switch-meta,
label {
  color: var(--muted);
  font-size: 0.88rem;
}

.new-list-form {
  display: grid;
  gap: 8px;
  margin-bottom: 20px;
}

.inline-control {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--ink);
  min-height: 42px;
  padding: 10px 12px;
}

textarea {
  min-height: 220px;
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.9rem;
}

.list-drawer-section {
  display: grid;
  gap: 8px;
  margin-bottom: 18px;
}

.list-drawer-section h2 {
  color: var(--muted);
  font-size: 0.76rem;
  letter-spacing: 0;
  text-transform: uppercase;
}

.list-nav {
  display: grid;
  align-content: start;
  gap: 8px;
  flex: 1 1 auto;
}

.drawer-empty,
.share-empty,
.share-message,
.share-panel p {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.list-switch {
  display: grid;
  gap: 2px;
  width: 100%;
  min-height: 62px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--ink);
  padding: 12px;
  text-align: left;
  transition:
    background 140ms ease,
    border-color 140ms ease,
    transform 140ms ease;
}

.list-switch:hover {
  border-color: rgba(47, 125, 85, 0.45);
  transform: translateY(-1px);
}

.list-switch[data-active="true"] {
  border-color: var(--leaf);
  background: #eff8f1;
}

.list-switch-title {
  overflow-wrap: anywhere;
  font-weight: 750;
}

.workspace {
  width: min(900px, 100%);
  margin: 0 auto;
  padding: 28px;
}

.workspace-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 16px;
  margin-bottom: 18px;
}

.workspace-header .drawer-toggle {
  display: none;
}

.title-stack {
  min-width: 0;
}

.title-stack p {
  margin: 0 0 4px;
  text-transform: uppercase;
  font-weight: 800;
}

h1,
h2,
p {
  overflow-wrap: anywhere;
}

h1 {
  margin: 0;
  font-size: 2rem;
  line-height: 1.1;
}

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

.list-toolbar,
.list-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.account-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.82);
  padding: 0 12px;
}

.account-pill[hidden] {
  display: none;
}

.account-pill span {
  max-width: 180px;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-actions {
  display: grid;
  gap: 6px;
  margin-top: 18px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.sidebar-actions .account-pill {
  width: 100%;
  justify-content: flex-start;
  margin-bottom: 4px;
}

.menu-item {
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  width: 100%;
  min-height: 40px;
  border: 0;
  border-radius: calc(var(--radius) - 2px);
  background: transparent;
  color: var(--ink);
  padding: 0 10px;
  font-weight: 750;
  text-align: left;
}

.menu-item:hover {
  background: #f2f7ef;
}

.menu-item.danger {
  color: var(--tomato-dark);
}

.menu-item:disabled {
  opacity: 0.48;
}

.menu-footer {
  margin-top: 8px;
  border-top: 1px solid var(--line);
  padding-top: 8px;
}

.list-details {
  display: grid;
}

.list-details[hidden] {
  display: none;
}

.list-controls {
  justify-content: space-between;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.76);
  padding: 14px;
  margin-bottom: 14px;
}

.rename-control {
  display: grid;
  gap: 6px;
  min-width: min(100%, 300px);
}

.stats-band {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.stats-band div {
  min-height: 84px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  padding: 16px;
}

.stats-band strong {
  display: block;
  font-size: 1.8rem;
  line-height: 1;
}

.stats-band span {
  color: var(--muted);
  font-weight: 700;
}

.item-form {
  display: grid;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  padding: 16px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
}

.share-panel {
  display: grid;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.78);
  padding: 14px;
  margin-bottom: 14px;
}

.share-form {
  display: grid;
  gap: 6px;
}

.share-form[hidden] {
  display: none;
}

.share-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.share-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #f7fbf4;
  color: var(--ink);
  padding: 0 8px 0 10px;
  font-size: 0.84rem;
  font-weight: 750;
}

.share-chip span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.share-remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--tomato-dark);
  font-weight: 850;
}

.share-remove:hover {
  background: #fff0ee;
}

.item-form-grid {
  display: grid;
  grid-template-columns: minmax(180px, 1.4fr) minmax(92px, 0.5fr) minmax(160px, 0.8fr);
  gap: 12px;
}

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

.field.wide:last-child {
  grid-column: 1 / -1;
}

.primary-button,
.icon-text-button,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  min-height: 42px;
  font-weight: 750;
  text-decoration: none;
  transition:
    background 140ms ease,
    border-color 140ms ease,
    color 140ms ease,
    transform 140ms ease;
}

.primary-button {
  width: fit-content;
  background: var(--leaf);
  color: white;
  padding: 0 16px;
}

.primary-button:hover {
  background: var(--leaf-dark);
  transform: translateY(-1px);
}

.icon-text-button {
  background: var(--leaf);
  color: white;
  padding: 0 12px;
}

.icon-text-button.muted {
  background: white;
  color: var(--ink);
  border-color: var(--line);
}

.icon-text-button.muted:hover {
  border-color: var(--sky);
}

.icon-text-button.danger,
.icon-button.danger {
  color: var(--tomato-dark);
}

.icon-text-button.subtle {
  background: #fff7f6;
  border-color: #f0c4bf;
}

.icon-text-button:disabled,
.icon-button:disabled {
  opacity: 0.5;
}

.icon-button {
  width: 42px;
  padding: 0;
  background: white;
  color: var(--ink);
  border-color: var(--line);
}

.icon-button:hover,
.icon-text-button:hover {
  transform: translateY(-1px);
}

svg {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
}

svg path {
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.list-toolbar {
  justify-content: space-between;
  margin-bottom: 14px;
}

.segmented-control {
  display: inline-grid;
  grid-template-columns: repeat(3, minmax(76px, 1fr));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: white;
}

.segmented-control button {
  min-height: 40px;
  border: 0;
  border-right: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  font-weight: 750;
  padding: 0 12px;
}

.segmented-control button:last-child {
  border-right: 0;
}

.segmented-control button[data-active="true"] {
  background: var(--ink);
  color: white;
}

.item-tabs {
  width: min(100%, 480px);
}

.item-tabs button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 0;
}

.tab-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  min-height: 24px;
  border-radius: 999px;
  background: #f2f7ef;
  color: var(--leaf-dark);
  padding: 0 7px;
  font-size: 0.78rem;
  font-weight: 850;
}

.segmented-control button[data-active="true"] .tab-count {
  background: rgba(255, 255, 255, 0.16);
  color: white;
}

.empty-state {
  display: grid;
  justify-items: center;
  gap: 8px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.65);
  padding: 28px 16px;
  text-align: center;
}

.empty-state[hidden] {
  display: none;
}

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

.item-list {
  display: grid;
  gap: 16px;
}

.category-section {
  display: grid;
  gap: 8px;
}

.category-section h2 {
  color: var(--leaf-dark);
  text-transform: uppercase;
  font-size: 0.82rem;
}

.item-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  min-height: 72px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  padding: 12px;
}

.item-row[data-checked="true"] {
  background: #f4f6f3;
}

.item-row[data-checked="true"] .item-content {
  color: var(--muted);
  text-decoration: line-through;
  text-decoration-thickness: 2px;
}

.check-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: 2px solid var(--leaf);
  border-radius: 50%;
  background: white;
  color: white;
}

.check-button[aria-pressed="true"] {
  background: var(--leaf);
}

.item-content {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.item-title-line {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.item-title-line strong {
  font-size: 1rem;
}

.item-pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border: 1px solid rgba(243, 195, 74, 0.9);
  border-radius: 999px;
  background: rgba(243, 195, 74, 0.22);
  color: #5a4200;
  padding: 0 10px;
  font-size: 0.84rem;
  font-weight: 800;
}

.item-meta {
  margin: 0;
}

.import-dialog {
  width: min(620px, calc(100vw - 24px));
  border: 0;
  border-radius: var(--radius);
  padding: 0;
  box-shadow: var(--shadow);
}

.import-dialog::backdrop {
  background: rgba(31, 42, 36, 0.42);
}

.dialog-shell {
  display: grid;
  gap: 12px;
  padding: 18px;
}

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

@media (max-width: 820px) {
  .app-shell {
    grid-template-columns: minmax(0, 1fr);
  }

  .drawer-overlay {
    position: fixed;
    inset: 0;
    z-index: 10;
    display: none;
    background: rgba(31, 42, 36, 0.35);
  }

  .app-shell.drawer-open .drawer-overlay {
    display: block;
  }

  .list-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 11;
    width: min(86vw, 320px);
    transform: translateX(-105%);
    transition: transform 180ms ease;
  }

  .app-shell.drawer-open .list-sidebar {
    transform: translateX(0);
  }

  .workspace {
    padding: 18px;
  }

  .workspace-header .drawer-toggle {
    display: inline-flex;
  }

  .workspace-header {
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 8px;
    margin-bottom: 12px;
  }

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

  .field.wide:last-child {
    grid-column: auto;
  }

  .stats-band {
    grid-template-columns: 1fr 1fr 1fr;
  }

  .stats-band div {
    min-height: 74px;
    padding: 12px;
  }

  .stats-band strong {
    font-size: 1.5rem;
  }

  .list-toolbar {
    position: sticky;
    top: 0;
    z-index: 3;
    align-items: stretch;
    gap: 8px;
    background: rgba(251, 253, 248, 0.94);
    padding: 6px 0;
  }

  .segmented-control {
    width: 100%;
  }

  .item-tabs {
    width: 100%;
  }
}

@media (max-width: 520px) {
  .workspace {
    padding: 14px;
  }

  h1 {
    font-size: 1.65rem;
  }

  .stats-band {
    grid-template-columns: 1fr;
  }

  .list-controls {
    align-items: stretch;
  }

  .list-controls > * {
    width: 100%;
  }

  .primary-button {
    width: 100%;
  }

  .item-row {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .item-row .icon-button.danger {
    grid-column: 2;
    justify-self: end;
  }
}
