:root {
  --bg: #0b1520;
  --card: #142236;
  --nav: #182a44;
  --accent: #ff7a45;
  --green: #62d477;
  --red: #ff6b6b;
  --amber: #f0c961;
  --blue: #4da6ff;
  --text: #ffffff;
  --muted: rgba(255, 255, 255, 0.62);
  --border: rgba(255, 255, 255, 0.12);
}

* { box-sizing: border-box; }

button, a, input, .tab, .chip, .icon-btn {
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}

button, .tab, .chip, .icon-btn {
  transition: transform 0.2s ease, opacity 0.2s ease;
  will-change: transform;
}
button.pressed, .tab.pressed, .chip.pressed, .icon-btn.pressed {
  transform: scale(0.92);
  opacity: 0.62;
  transition: none;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

body {
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
  min-height: 100vh;
}

/* ---------- login ---------- */
.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}

.login-card {
  width: 100%;
  max-width: 340px;
  padding: 32px 28px 40px;
  text-align: center;
}

.login-logo {
  width: 88px;
  height: 88px;
  border-radius: 22px;
  margin-bottom: 12px;
}

.login-card h1 {
  font-size: 22px;
  margin: 0 0 4px;
}

.login-sub {
  color: var(--muted);
  font-size: 14px;
  margin-bottom: 28px;
}

.login-form input[type="password"] {
  width: 100%;
  padding: 14px 16px;
  border-radius: 12px;
  border: 1.5px solid var(--border);
  background: var(--card);
  color: var(--text);
  font-size: 18px;
  text-align: center;
  letter-spacing: 4px;
  margin-bottom: 16px;
}

.login-form button {
  width: 100%;
  padding: 14px;
  border-radius: 12px;
  border: none;
  background: var(--accent);
  color: #1a0f08;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
}

.login-error {
  color: var(--red);
  font-size: 14px;
  margin-bottom: 12px;
}

/* ---------- topbar ---------- */
#topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  padding: env(safe-area-inset-top) 0 0;
  background: var(--bg);
}

.header-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

#topbar-title {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 17px;
  font-weight: 700;
}

#topbar-logo {
  width: 26px;
  height: 26px;
  border-radius: 7px;
}

.icon-btn {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  border: none;
  background: var(--card);
  color: var(--text);
  font-size: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}

.icon-btn[hidden] { display: none; }

.icon-btn:disabled {
  opacity: 0.5;
}

/* ---------- main app ---------- */
#app {
  padding: 12px 14px 40px;
  max-width: 640px;
  margin: 0 auto;
}

.search-row {
  margin-bottom: 10px;
}

.search-input {
  width: 100%;
  padding: 11px 14px;
  border-radius: 12px;
  border: 1.5px solid var(--border);
  background: var(--card);
  color: var(--text);
  font-size: 15px;
}

.search-input::placeholder { color: var(--muted); }

.tab-row {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}

.freshness-row {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 12px;
  text-align: center;
}

.icon-btn.spinning {
  animation: icon-spin 0.8s linear infinite;
}

@keyframes icon-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.tab {
  flex: 1;
  padding: 10px 8px;
  border-radius: 12px;
  border: 1.5px solid var(--border);
  background: var(--card);
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
  text-align: center;
  cursor: pointer;
}

.tab.active {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(255, 122, 69, 0.12);
}

.tab-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
  margin-left: 5px;
  vertical-align: middle;
}

.tab.active .tab-badge {
  background: var(--accent);
  color: #1a0f08;
}

.chip-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border: 1.5px solid var(--border);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.04);
  cursor: pointer;
  white-space: nowrap;
}

.chip.active {
  border-color: var(--blue);
  color: var(--blue);
  background: rgba(77, 166, 255, 0.14);
}

.chip-cnt { opacity: 0.7; font-size: 11.5px; }

.item-card {
  background: var(--card);
  border-radius: 14px;
  padding: 13px 15px;
  margin-bottom: 10px;
  border: 1px solid var(--border);
  position: relative;
  z-index: 2;
}

.item-card[data-open="1"] {
  cursor: pointer;
}

.item-card-order {
  background: #000000;
  border-color: rgba(255, 255, 255, 0.16);
}

/* ---------- swipe-to-complete ---------- */
.item-card-wrap {
  position: relative;
  border-radius: 14px;
  margin-bottom: 10px;
  overflow: hidden;
}

.item-card-wrap .item-card {
  margin-bottom: 0;
  transition: transform 0.22s ease;
}

.item-card-wrap.collapsing {
  max-height: 0 !important;
  margin-bottom: 0;
  transition: max-height 0.3s ease, margin-bottom 0.3s ease;
}

.swipe-reveal {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 22px;
  background: var(--green);
  border-radius: 14px;
}

.swipe-reveal-btn {
  color: #06210f;
  font-weight: 700;
  font-size: 14px;
}

.item-title-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.35;
}

.item-emoji { flex-shrink: 0; font-size: 15px; }

.item-fraction {
  margin-left: 6px;
  font-weight: 700;
  color: var(--blue);
}

.item-label {
  display: inline-block;
  margin-top: 6px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.06);
  border-radius: 999px;
  padding: 3px 10px;
}

.item-meta {
  margin-top: 8px;
  font-size: 12.5px;
  color: var(--muted);
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.empty-state {
  text-align: center;
  color: var(--muted);
  padding: 60px 20px;
  font-size: 15px;
}

.push-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--nav);
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 12px;
  font-size: 13.5px;
}

.push-banner button {
  border: none;
  background: var(--accent);
  color: #1a0f08;
  font-weight: 700;
  border-radius: 10px;
  padding: 8px 14px;
  font-size: 13px;
  cursor: pointer;
  flex-shrink: 0;
}

.toast {
  position: fixed;
  bottom: calc(24px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  background: var(--nav);
  color: var(--text);
  padding: 10px 18px;
  border-radius: 10px;
  font-size: 14px;
  z-index: 999;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
}

.spinner {
  text-align: center;
  padding: 40px;
  color: var(--muted);
}
