:root {
  font-family:
    system-ui,
    -apple-system,
    Segoe UI,
    Roboto,
    Helvetica,
    Arial,
    sans-serif;
  font-size: 16px;
  line-height: 1.35;

  --bg: #0b0b0f;
  --card: rgba(28, 28, 30, 0.85);
  --card-border: rgba(255, 255, 255, 0.08);
  --text: rgba(255, 255, 255, 0.92);
  --muted: rgba(255, 255, 255, 0.6);
  --subtle: rgba(255, 255, 255, 0.1);
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  --radius: 16px;

  --control-h: 44px;
  --control-r: 14px;

  --form-max: 520px;
  --add-max: 700px;
  --shop-col: 160px;
}

html,
body {
  height: 100%;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    radial-gradient(
      1200px 600px at 20% 0%,
      rgba(50, 50, 70, 0.35),
      transparent 50%
    ),
    radial-gradient(
      900px 500px at 80% 20%,
      rgba(70, 50, 90, 0.25),
      transparent 55%
    ),
    var(--bg);
  color: var(--text);
}

.wrap {
  max-width: 820px;
  margin: 0 auto;
  padding: 18px 16px 28px;
}

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

h1 {
  margin: 8px 0;
  font-size: 22px;
  letter-spacing: -0.02em;
}

h2 {
  margin: 14px 0 12px 0;
  font-size: 13px;
  color: var(--muted);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.row.end {
  justify-content: flex-end;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Controls */
input[type="text"],
input[type="password"],
select {
  width: 100%;
  height: var(--control-h);
  padding: 0 12px;
  border-radius: var(--control-r);
  border: 1px solid var(--subtle);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  outline: none;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
  font-size: 16px; /* iOS zoom fix */
  line-height: 1.2;
}

input::placeholder {
  color: rgba(255, 255, 255, 0.35);
}

input:focus,
select:focus {
  border-color: rgba(255, 255, 255, 0.22);
  background: rgba(255, 255, 255, 0.08);
}

select {
  appearance: none;
  -webkit-appearance: none;
}

button {
  height: var(--control-h);
  padding: 0 16px;
  border-radius: var(--control-r);
  border: 1px solid var(--subtle);
  background: rgba(255, 255, 255, 0.12);
  color: var(--text);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

button:active {
  transform: translateY(0.5px);
}

button.ghost {
  height: auto;
  background: transparent;
  border-color: transparent;
  padding: 8px 10px;
  color: var(--muted);
  font-weight: 650;
}

button.ghost:hover {
  color: var(--text);
}

#btnRefresh {
  font-size: 18px;
  line-height: 1;
  padding: 8px 10px;
}

button.linkish {
  height: auto;
  background: transparent;
  border: none;
  padding: 6px 0;
  text-align: left;
  font: inherit;
  color: var(--text);
  text-decoration: none;
}

button.linkish:hover {
  text-decoration: underline;
  text-decoration-color: rgba(255, 255, 255, 0.35);
}

.ptr {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  justify-content: center;
  pointer-events: none;
  padding: 8px 0 0;
}

.ptrText {
  font-size: 13px;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.65);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  padding: 6px 10px;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

/* Forms sizing */
#loginForm {
  max-width: var(--form-max);
  margin: 0 auto;
}

#loginForm button {
  width: 100%;
  font-size: 16px;
}

#addForm {
  max-width: var(--add-max);
  margin: 0 auto 14px auto;
  display: grid;
  grid-template-columns: var(--shop-col) minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
}

#newText {
  min-width: 0;
}

/* "+" button (assumes id="btnAdd") */
#btnAdd {
  width: var(--control-h);
  padding: 0;
  font-size: 22px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
}

#btnLogout,
#btnClearDone {
  font-size: 15px;
  font-weight: 700;
}

@media (max-width: 520px) {
  #addForm {
    max-width: 100%;
    grid-template-columns: 1fr;
  }
}

/* Content split */
.split {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
  margin-top: 10px;
}

@media (min-width: 700px) {
  .split {
    grid-template-columns: 1fr 1fr;
  }
}

.split > section {
  padding-top: 6px;
}

/* Lists */
.list {
  list-style: none;
  padding: 0;
  margin: 6px 0 0 0;
}

/* Items list rows: checkbox | text | qty | delete */
.li {
  display: grid;
  grid-template-columns: 34px 1fr auto 38px;
  align-items: center;
  gap: 12px;
  padding: 14px 6px;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
}

.li:first-child {
  border-top: none;
}

/* History list rows are simpler */
.liHistory {
  display: block;
  padding: 10px 6px;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
}

.liHistory:first-child {
  border-top: none;
}

/* Custom checkbox */
.cb {
  width: 26px;
  height: 26px;
  border-radius: 9px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.06);
  display: inline-block;
  position: relative;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.cb input {
  appearance: none;
  -webkit-appearance: none;
  width: 0;
  height: 0;
  margin: 0;
}

.cb .mark {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 12px;
  height: 7px;
  border-left: 3px solid transparent;
  border-bottom: 3px solid transparent;
  transform: translate(-50%, -60%) rotate(-45deg);
  opacity: 0;
}

.cb[data-checked="1"] {
  background: rgba(255, 255, 255, 0.16);
  border-color: rgba(255, 255, 255, 0.22);
}

.cb[data-checked="1"] .mark {
  border-left-color: rgba(255, 255, 255, 0.9);
  border-bottom-color: rgba(255, 255, 255, 0.9);
  opacity: 1;
}

.liEmpty {
  padding: 12px 6px;
  color: rgba(255, 255, 255, 0.55);
  border-top: 1px solid rgba(255, 255, 255, 0.07);
}

.liEmpty:first-child {
  border-top: none;
}

.itemText {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  letter-spacing: -0.01em;
}

.itemText.done {
  text-decoration: line-through;
  color: rgba(255, 255, 255, 0.55);
}

/* Qty UI */
.qtyHost {
  display: inline-flex;
  justify-content: flex-end;
}

.qtyPill {
  height: 30px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.06);
  color: rgba(255, 255, 255, 0.9);
  font-size: 13px;
  font-weight: 700;
}

.qtyPill.empty {
  color: rgba(255, 255, 255, 0.55);
  border-color: rgba(255, 255, 255, 0.1);
}

.qtyInput {
  width: 92px;
  height: 30px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  outline: none;
  font-size: 14px;
  line-height: 1;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 13px;
}

.err {
  color: #ff6b6b;
  margin: 0;
}

.hidden {
  display: none !important;
}
