* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic", sans-serif;
  background: #f5f5f2;
  color: #2b2b2b;
}

h1 {
  font-size: 1.25rem;
  margin: 0;
}

/* --- auth page --- */

.auth-page {
  max-width: 420px;
  margin: 0 auto;
  padding: 2rem 1rem;
}

.card {
  background: #fff;
  border-radius: 12px;
  padding: 1.25rem;
  margin-top: 1.5rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

label {
  display: flex;
  flex-direction: column;
  font-size: 0.85rem;
  gap: 0.25rem;
}

input,
select {
  font-size: 1rem;
  padding: 0.6rem;
  border: 1px solid #ccc;
  border-radius: 8px;
}

.btn-primary {
  font-size: 1rem;
  padding: 0.75rem;
  border: none;
  border-radius: 8px;
  background: #3a7d5c;
  color: #fff;
  min-height: 44px;
  cursor: pointer;
}

.btn-primary:active {
  background: #2f6449;
}

.link-btn {
  background: none;
  border: none;
  color: #3a7d5c;
  text-decoration: underline;
  cursor: pointer;
  font-size: 0.9rem;
  padding: 0.5rem 0;
}

.error {
  color: #c0392b;
  min-height: 1.2em;
  font-size: 0.9rem;
}

/* --- app header/tabs --- */

.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1rem;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  position: sticky;
  top: 0;
  z-index: 10;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.85rem;
  color: #666;
}

.tabs {
  display: flex;
  position: sticky;
  top: 48px;
  z-index: 9;
  background: #fff;
  border-bottom: 1px solid #e0e0dc;
}

.tab-btn {
  flex: 1;
  padding: 0.85rem 0;
  border: none;
  background: none;
  font-size: 0.95rem;
  color: #888;
  min-height: 44px;
  cursor: pointer;
  border-bottom: 3px solid transparent;
}

.tab-btn.active {
  color: #3a7d5c;
  border-bottom-color: #3a7d5c;
  font-weight: bold;
}

main {
  max-width: 640px;
  margin: 0 auto;
  padding: 1rem;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.quick-add {
  flex-direction: row;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.quick-add input,
.quick-add select {
  flex: 1;
  min-width: 100px;
}

.quick-add .btn-primary {
  flex: 0 0 auto;
  padding: 0.6rem 1rem;
}

/* --- item list --- */

.item-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.item-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  background: #fff;
  border-radius: 10px;
  padding: 0.85rem 1rem;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

.item-row .item-main {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

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

.item-row .item-sub {
  font-size: 0.8rem;
  color: #888;
}

.tap-toggle {
  min-height: 44px;
  min-width: 88px;
  border: none;
  border-radius: 22px;
  font-size: 0.9rem;
  cursor: pointer;
  padding: 0 1rem;
}

.tap-toggle.status-in_stock {
  background: #e4f0e9;
  color: #3a7d5c;
}

.tap-toggle.status-buy_list {
  background: #fbe8e4;
  color: #c0392b;
}

.tap-toggle.task-complete {
  background: #3a7d5c;
  color: #fff;
}

.empty-state {
  text-align: center;
  color: #999;
  padding: 2rem 0;
}

@media (prefers-color-scheme: dark) {
  body {
    background: #1c1c1e;
    color: #eee;
  }

  .card,
  .app-header,
  .tabs,
  .item-row {
    background: #2b2b2d;
    box-shadow: none;
  }

  input,
  select {
    background: #1c1c1e;
    color: #eee;
    border-color: #444;
  }

  .tap-toggle.status-in_stock {
    background: #234433;
    color: #8fd6ac;
  }

  .tap-toggle.status-buy_list {
    background: #442525;
    color: #f0a297;
  }
}
