/* ============================================================
   Grabbit — slick, mobile-first, dark-mode-aware stylesheet
   ============================================================ */
:root {
  --brand:      #10b981;
  --brand-dark: #059669;
  --brand-deep: #047857;
  --brand-soft: #d1fae5;
  --accent:     #0ea5e9;
  --danger:     #ef4444;
  --danger-soft:#fee2e2;
  --amber:      #f59e0b;
  --ink:        #0f172a;
  --muted:      #64748b;
  --line:       #e5e9ef;
  --bg:         #f4f7f9;
  --card:       #ffffff;
  --hover:      #eef2f6;
  --shadow:     0 8px 30px rgba(16,40,32,.10);
  --shadow-sm:  0 2px 10px rgba(16,40,32,.06);
  --radius:     18px;
  --radius-sm:  12px;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}
html.dark {
  --brand:      #34d399;
  --brand-dark: #10b981;
  --brand-deep: #059669;
  --brand-soft: #14532d;
  --ink:        #e8eef4;
  --muted:      #93a4b5;
  --line:       #223041;
  --bg:         #0b1220;
  --card:       #131c2b;
  --hover:      #1c2637;
  --shadow:     0 8px 30px rgba(0,0,0,.35);
  --shadow-sm:  0 2px 10px rgba(0,0,0,.3);
  --danger-soft:#3b1414;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font); background: var(--bg); color: var(--ink);
  -webkit-font-smoothing: antialiased; line-height: 1.45;
  overscroll-behavior-y: none;
}
button { font-family: inherit; cursor: pointer; }
input, select, button, textarea { font-size: 16px; }
a { color: var(--brand-dark); }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: .84rem; }
.center { text-align: center; }
.pad { padding: 14px; }
.mt { margin-top: 12px; }
.spacer { flex: 1; }

/* ---------- Buttons ---------- */
.btn {
  border: none; border-radius: var(--radius-sm); padding: 11px 16px; font-weight: 650; color: #fff;
  background: var(--brand); transition: background-color .15s, transform .05s, opacity .15s;
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
}
.btn:hover { background: var(--brand-dark); }
.btn:active { transform: translateY(1px); }
.btn-block { width: 100%; }
.btn-sm { padding: 7px 11px; font-size: 14px; border-radius: 9px; }
.btn-ghost { background: transparent; color: var(--ink); border: 1.5px solid var(--line); }
.btn-ghost:hover { background: var(--hover); }
.btn-danger { background: var(--danger); }
.btn-danger:hover { background: #dc2626; }
.btn-danger-ghost { background: transparent; color: var(--danger); border: 1.5px solid var(--danger); }
.btn-danger-ghost:hover { background: var(--danger-soft); }
.icon-btn {
  border: none; background: transparent; color: var(--muted);
  width: 38px; height: 38px; border-radius: 10px; font-size: 18px;
  display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto;
}
.icon-btn:hover { background: var(--hover); color: var(--ink); }
.icon-btn.sm { width: 32px; height: 32px; font-size: 16px; }
.icon-btn.light { color: #fff; }
.icon-btn.light:hover { background: rgba(255,255,255,.18); color: #fff; }

/* ---------- Inputs ---------- */
input[type=text], input[type=password], input[type=number], input[type=email], select, textarea {
  width: 100%; padding: 12px 13px; border: 1.5px solid var(--line); border-radius: var(--radius-sm);
  background: var(--card); color: var(--ink); transition: border-color .15s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); }
label.field { display: block; font-size: 13px; color: var(--muted); margin-bottom: 5px; font-weight: 650; }
.field-row { margin-bottom: 13px; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* ============================================================ Login */
.login-wrap {
  min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 22px;
  background: linear-gradient(160deg, #34d399 0%, #10b981 45%, #047857 100%);
}
.login-card {
  background: var(--card); border-radius: 26px; box-shadow: var(--shadow);
  width: 100%; max-width: 380px; padding: 34px 28px; text-align: center;
}
.login-logo { display: inline-flex; margin-bottom: 8px; filter: drop-shadow(0 6px 12px rgba(5,150,105,.25)); }
.login-card h1 { font-size: 1.5rem; margin: 4px 0 2px; }
.login-card .sub { color: var(--muted); font-size: .95rem; margin: 0 0 22px; }
.login-error { background: var(--danger-soft); color: var(--danger); border-radius: 10px; padding: 10px 12px; font-size: .88rem; margin-bottom: 14px; }
.gbtn-wrap { display: flex; justify-content: center; min-height: 44px; }
.login-spin { color: var(--muted); padding: 12px; }
.login-terms { color: var(--muted); font-size: .78rem; margin: 20px 0 10px; line-height: 1.5; }
.login-lang { margin-top: 6px; }

/* ============================================================ Top bar */
.topbar {
  position: sticky; top: 0; z-index: 30;
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-deep) 100%);
  color: #fff; padding: 10px 14px; box-shadow: var(--shadow-sm);
  padding-top: max(10px, env(safe-area-inset-top));
}
.topbar-inner { max-width: 720px; margin: 0 auto; display: flex; align-items: center; gap: 10px; }
.brand { display: flex; align-items: center; gap: 9px; font-weight: 750; font-size: 1.12rem; }
.brand-logo { display: inline-flex; }
.topbar-spacer { flex: 1; }
.save-pill { font-size: 15px; min-width: 18px; opacity: .9; }

/* ============================================================ Layout */
.container { max-width: 720px; margin: 0 auto; padding: 14px; padding-bottom: max(20px, env(safe-area-inset-bottom)); }
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 15px; margin-bottom: 14px; }
.card h2 { margin: 0; font-size: 1.05rem; display: flex; align-items: center; gap: 7px; }
.section-head { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.badge { display: inline-block; font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 999px; background: var(--brand-soft); color: var(--brand-deep); }
html.dark .badge { color: var(--brand); }
.badge.readonly { background: var(--hover); color: var(--muted); }
.empty-state { text-align: center; padding: 40px 16px; }
.empty-state .big { display: inline-flex; margin-bottom: 8px; }
.hint { text-align: center; margin-top: 10px; }

/* ---------- List selector ---------- */
.selector { padding: 12px 15px; }
.selector-row { display: flex; gap: 8px; align-items: center; }
.list-select { flex: 1; font-weight: 600; }
.selector-actions { display: flex; align-items: center; gap: 6px; margin-top: 10px; }

/* ---------- Add card ---------- */
.add-card { position: sticky; top: 62px; z-index: 20; }
.combo { position: relative; display: flex; gap: 8px; }
.combo #addInput { flex: 1; }
.add-btn { flex: 0 0 auto; padding: 12px 16px; font-size: 20px; line-height: 1; }
.combo-menu {
  display: none; position: absolute; top: 52px; left: 0; right: 62px; z-index: 40;
  background: var(--card); border: 1.5px solid var(--line); border-radius: var(--radius-sm);
  box-shadow: var(--shadow); overflow: hidden; max-height: 280px; overflow-y: auto;
}
.combo-menu.show { display: block; }
.combo-opt { padding: 11px 13px; cursor: pointer; }
.combo-opt:hover { background: var(--hover); }
.search-mini { display: flex; gap: 8px; margin-top: 10px; }
.search-mini input { flex: 1; }
.group-sel { flex: 0 0 auto; width: auto; }

/* ---------- Items ---------- */
.items { display: flex; flex-direction: column; gap: 7px; }
.item {
  display: flex; align-items: center; gap: 10px; padding: 10px 11px;
  background: var(--card); border: 1.5px solid var(--line); border-radius: 13px;
}
.item.done { opacity: .72; }
.chk {
  flex: 0 0 auto; width: 26px; height: 26px; border-radius: 50%; border: 2.2px solid var(--brand);
  background: transparent; color: #fff; font-size: 15px; display: inline-flex; align-items: center; justify-content: center;
  transition: background .12s;
}
.chk.on, .item:not(.done) .chk:active { background: var(--brand); }
.it-main { flex: 1; min-width: 0; cursor: pointer; display: flex; align-items: baseline; gap: 7px; flex-wrap: wrap; }
.it-name { font-weight: 550; }
.it-main .q { font-size: .82rem; color: var(--brand-dark); background: var(--brand-soft); padding: 1px 7px; border-radius: 999px; font-weight: 650; }
html.dark .it-main .q { color: var(--brand); }
.it-note { font-size: .8rem; color: var(--muted); width: 100%; }
.struck { text-decoration: line-through; color: var(--muted); }
.stepper { display: flex; align-items: center; gap: 2px; flex: 0 0 auto; }
.stepper button { width: 30px; height: 30px; border-radius: 8px; border: 1.5px solid var(--line); background: var(--card); color: var(--ink); font-size: 17px; line-height: 1; }
.stepper button:hover { background: var(--hover); }
.stepper span { min-width: 22px; text-align: center; font-weight: 650; font-size: .92rem; }
.drag-ghost { opacity: .4; }
.cat-group { margin-bottom: 12px; }
.cat-head { font-size: .82rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; padding: 4px 2px 8px; display: flex; align-items: center; gap: 6px; }
.cat-n { background: var(--hover); border-radius: 999px; padding: 0 7px; font-size: .78rem; }

/* ---------- Drawer ---------- */
#drawer:empty { display: none; }
.drawer-backdrop { position: fixed; inset: 0; background: rgba(4,10,20,.45); z-index: 90; animation: fade .15s; }
.drawer-panel {
  position: fixed; top: 0; right: 0; bottom: 0; width: 82%; max-width: 300px; z-index: 91;
  background: var(--card); box-shadow: var(--shadow); padding: 14px; animation: slideIn .2s ease;
  padding-top: max(14px, env(safe-area-inset-top));
}
.drawer-head { display: flex; align-items: center; gap: 9px; font-size: 1.1rem; padding: 4px 4px 14px; border-bottom: 1px solid var(--line); margin-bottom: 10px; }
.drawer-item { width: 100%; text-align: left; background: transparent; border: none; color: var(--ink); padding: 13px 12px; border-radius: 12px; font-size: 1rem; display: flex; align-items: center; gap: 12px; }
.drawer-item:hover { background: var(--hover); }
.drawer-item.active { background: var(--brand-soft); color: var(--brand-deep); font-weight: 650; }
html.dark .drawer-item.active { color: var(--brand); }
.di-ic { font-size: 1.2rem; }
@keyframes slideIn { from { transform: translateX(100%); } to { transform: translateX(0); } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* ---------- Modal ---------- */
#modal:empty { display: none; }
.modal-backdrop { position: fixed; inset: 0; background: rgba(4,10,20,.5); z-index: 100; animation: fade .15s; }
.modal-card {
  position: fixed; z-index: 101; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: calc(100% - 32px); max-width: 440px; max-height: 88dvh; overflow-y: auto;
  background: var(--card); border-radius: 20px; box-shadow: var(--shadow); padding: 22px;
}
.modal-card h2 { margin: 0 0 14px; font-size: 1.2rem; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; flex-wrap: wrap; }
.kind-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 6px 0; }
.kind-btn { border: 1.5px solid var(--line); background: var(--card); color: var(--ink); border-radius: 16px; padding: 22px 10px; display: flex; flex-direction: column; align-items: center; gap: 8px; font-weight: 600; }
.kind-btn:hover { border-color: var(--brand); background: var(--hover); }
.k-ico { font-size: 2rem; }

/* ---------- Share ---------- */
.share-add { display: grid; grid-template-columns: 1fr auto auto; gap: 8px; margin: 12px 0; }
.share-err { background: var(--danger-soft); color: var(--danger); border-radius: 9px; padding: 8px 11px; font-size: .85rem; margin-bottom: 10px; }
.share-list { display: flex; flex-direction: column; gap: 7px; }
.share-owner { display: flex; align-items: center; gap: 8px; padding: 9px 11px; background: var(--hover); border-radius: 11px; font-weight: 600; }
.share-item { display: flex; align-items: center; gap: 9px; padding: 8px 11px; border: 1.5px solid var(--line); border-radius: 11px; }
.share-item span:first-child { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.share-item.pending { opacity: .8; border-style: dashed; }

/* ---------- History ---------- */
.hist-list { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.hist-row { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1.5px solid var(--line); border-radius: 12px; }
.hist-row > div:first-child { flex: 1; min-width: 0; }

/* ---------- Account & settings ---------- */
.account-row { display: flex; align-items: center; gap: 13px; margin: 6px 0; }
.avatar { width: 52px; height: 52px; border-radius: 50%; object-fit: cover; }
.avatar.ph { background: var(--brand); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-size: 1.4rem; font-weight: 700; }
.acc-name { font-weight: 650; font-size: 1.05rem; }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.set-row:last-of-type { border-bottom: none; }
.segbar { display: inline-flex; background: var(--hover); border-radius: 10px; padding: 3px; gap: 2px; }
.seg { border: none; background: transparent; color: var(--muted); padding: 7px 13px; border-radius: 8px; font-weight: 600; font-size: .9rem; }
.seg.active { background: var(--card); color: var(--brand-dark); box-shadow: var(--shadow-sm); }
html.dark .seg.active { color: var(--brand); }
.about-logo { display: flex; justify-content: center; margin: 6px 0; }
.about p { margin: 5px 0; }

/* ---------- Lang toggle (login) ---------- */
.lang-toggle { display: inline-flex; background: var(--hover); border-radius: 9px; overflow: hidden; }
.lang-toggle button { border: none; background: transparent; color: var(--muted); padding: 6px 13px; font-weight: 700; font-size: 13px; }
.lang-toggle button.active { background: var(--brand); color: #fff; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: var(--bg); padding: 12px 20px; border-radius: 999px; font-size: .9rem; font-weight: 550;
  box-shadow: var(--shadow); opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 200; max-width: 90%;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (max-width: 420px) {
  .share-add { grid-template-columns: 1fr; }
  .two-col { grid-template-columns: 1fr; }
}
