@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
  --bg: #121214;
  --card: #1f1f22;
  --card-strong: #2b2221;
  --text: #efeff2;
  --muted: #8a8a92;
  --line: rgba(255, 255, 255, 0.09);
  --accent: #f0734a;
  --accent-soft: rgba(240, 115, 74, 0.16);
  --green: #3fdf7e;
  --green-soft: rgba(52, 211, 122, 0.15);
  --red: #ef5a5a;
  --red-soft: rgba(239, 90, 90, 0.16);
  --button-dark: #3a2927;
  --chip-dark: #2a2a2f;
  --radius: 12px;
  color-scheme: dark;
}

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

body {
  margin: 0;
  font-family: 'Inter', -apple-system, sans-serif;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

body.has-image-viewer {
  overflow: hidden;
}

button,
input {
  font: inherit;
}

.shell {
  max-width: 680px;
  margin: 0 auto;
  padding: 14px;
  padding-bottom: env(safe-area-inset-bottom, 16px);
}

.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.title-block {
  min-width: 0;
  flex: 1;
}

.title-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
}

.topbar h1 {
  font-size: 1.5rem;
  font-weight: 700;
  margin: 0;
  min-width: 0;
  letter-spacing: -0.02em;
}

.title-lock {
  font-size: 0.8em;
  vertical-align: 0.02em;
  opacity: 0.92;
}

.status {
  font-size: 0.8rem;
  color: var(--muted);
  white-space: nowrap;
}

.back-link {
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: inherit;
  text-decoration: none;
  flex-shrink: 0;
}

.back-link svg {
  width: 16px;
  height: 16px;
  color: var(--muted);
  flex-shrink: 0;
}

.add-bar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 76px 56px;
  gap: 8px;
  margin-bottom: 22px;
}

.add-bar input {
  min-width: 0;
  padding: 12px 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 18px;
  background: var(--card);
  color: var(--text);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.03);
}

.add-bar input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(240, 115, 74, 0.18);
}

.add-bar input::placeholder {
  color: #5d5d64;
}

.add-bar #item-name {
  flex: 1;
}

.add-bar .qty-input {
  width: 76px;
  text-align: center;
  font-size: 1.05rem;
}

.add-bar button {
  width: 56px;
  border: none;
  border-radius: 18px;
  background: var(--accent);
  color: #fff;
  font-size: 1.15rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 6px 16px rgba(240, 115, 74, 0.22);
}

.progress-track {
  height: 4px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 999px;
  margin-bottom: 18px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--green));
  border-radius: 999px;
  transition: width 250ms ease;
}

.section-label {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 18px 0 10px;
  font-size: 0.75rem;
  font-weight: 800;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.badge {
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 0.75rem;
  font-weight: 700;
}

.section-label--pending .badge {
  background: var(--accent-soft);
  color: var(--accent);
}

.section-label--activity .badge {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
}

#pending-items .item {
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.03),
    0 8px 22px rgba(0, 0, 0, 0.16);
}

#pending-items .item-name {
  font-size: 1.04rem;
  font-weight: 800;
}

#pending-items .item-note-text {
  color: rgba(239, 239, 242, 0.78);
}

#activity-section {
  opacity: 0.58;
  transition: opacity 180ms ease;
}

#activity-section:hover,
#activity-section:focus-within {
  opacity: 0.84;
}

#activity-items .item-name {
  font-size: 0.94rem;
  font-weight: 700;
}

#activity-items .item-note-text {
  color: rgba(138, 138, 146, 0.86);
}

#activity-items .item-qty,
#activity-items .state-pill {
  opacity: 0.88;
}

.item-list,
.list-grid {
  list-style: none;
  margin: 0;
  padding: 0;
}

.item {
  margin-bottom: 8px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--card);
  overflow: hidden;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.02);
}

.item[data-status="pending"] {
  background: linear-gradient(180deg, rgba(240, 115, 74, 0.07), transparent 60%), var(--card-strong);
  border-color: rgba(240, 115, 74, 0.18);
}

.item[data-status="bought"] {
  border-left: 5px solid var(--green);
}

.item[data-status="removed"] {
  border-left: 5px solid var(--red);
}

.item[data-busy="true"] {
  opacity: 0.78;
}

.item-row {
  display: grid;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
}

.item-row--pending {
  grid-template-columns: 46px minmax(0, 1fr) 54px;
}

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

.item-core {
  min-width: 0;
  border: none;
  background: transparent;
  color: inherit;
  padding: 0;
  text-align: left;
  cursor: pointer;
}

.item-core:disabled {
  cursor: default;
}

.item-title-line {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 10px;
}

.item-title-line--activity {
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  margin-bottom: 4px;
}

.item-name {
  min-width: 0;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  font-size: 0.98rem;
  line-height: 1.28;
  font-weight: 700;
  word-break: break-word;
}

.item-qty {
  flex-shrink: 0;
  margin-top: 1px;
  border-radius: 999px;
  padding: 4px 10px;
  background: var(--chip-dark);
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 700;
}

.item-subline {
  display: flex;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 6px 8px;
  margin-top: 4px;
}

.item-subline--activity {
  display: grid;
  gap: 6px;
}

.item-note-text {
  min-width: 0;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.38;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  word-break: break-word;
}

.item-state-text {
  color: var(--accent);
  font-size: 0.74rem;
  font-weight: 600;
}

.item-attachment {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--accent);
  font-size: 0.74rem;
  font-weight: 700;
}

.item-attachment::before {
  content: '\1F4CE';
  font-size: 0.9rem;
  line-height: 1;
}

.item-details {
  display: grid;
  gap: 10px;
  padding: 0 16px 16px;
}

.order-card {
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(255, 255, 255, 0.03);
  padding: 12px;
}

.order-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.order-by {
  min-width: 0;
  color: var(--text);
  font-size: 0.8rem;
  font-weight: 700;
  word-break: break-word;
}

.order-qty {
  flex-shrink: 0;
  color: var(--muted);
  font-size: 0.73rem;
  font-weight: 700;
}

.order-note {
  margin: 0;
  color: var(--muted);
  font-size: 0.77rem;
  line-height: 1.4;
  word-break: break-word;
}

.order-media-strip {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.order-media-button {
  width: 100%;
  display: block;
  padding: 0;
  border: none;
  background: transparent;
  color: inherit;
  cursor: zoom-in;
}

.order-media {
  width: 100%;
  display: block;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  background: #0f0f12;
}

.order-media--image,
.order-media--video {
  max-height: 220px;
  object-fit: cover;
}

.order-media--audio {
  min-height: 44px;
  height: 44px;
  max-height: 44px;
}

.image-viewer {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(0, 0, 0, 0.9);
  cursor: zoom-out;
}

.image-viewer__image {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 8px;
  cursor: zoom-out;
}

.image-viewer__close {
  position: fixed;
  top: max(14px, env(safe-area-inset-top));
  right: max(14px, env(safe-area-inset-right));
  width: 44px;
  height: 44px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  background: rgba(20, 20, 22, 0.9);
  color: var(--text);
  font-size: 1.8rem;
  line-height: 1;
  cursor: pointer;
}

.state-pill {
  flex-shrink: 0;
  border-radius: 999px;
  width: fit-content;
  padding: 4px 12px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.state-pill--bought {
  background: var(--green-soft);
  color: var(--green);
}

.state-pill--removed {
  background: var(--red-soft);
  color: var(--red);
}

.icon-btn {
  width: 46px;
  height: 46px;
  border: none;
  border-radius: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.icon-btn svg {
  width: 23px;
  height: 23px;
}

.icon-btn:disabled {
  opacity: 0.45;
  cursor: default;
}

.icon-btn--danger {
  color: var(--red);
  background: rgba(239, 90, 90, 0.12);
}

.icon-btn--success {
  color: #fff;
  background: var(--green);
}

.icon-btn--accent {
  color: var(--accent);
  background: var(--button-dark);
}

.icon-btn--save {
  color: var(--accent);
}

.icon-btn--ghost {
  color: var(--muted);
}

.edit-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 80px;
  gap: 8px;
  padding: 0 16px 16px;
}

.edit-form input {
  min-width: 0;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #17171a;
  color: var(--text);
}

.edit-form input:focus {
  outline: none;
  border-color: var(--accent);
}

.edit-form input[name="note"] {
  grid-column: 1 / -1;
}

.edit-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.item[data-expanded="true"] .item-name,
.item[data-expanded="true"] .item-note-text {
  -webkit-line-clamp: unset;
  overflow: visible;
}

.empty {
  padding: 22px 8px;
  text-align: center;
  color: var(--muted);
  font-size: 0.84rem;
}

.list-grid a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 14px 16px;
  margin-bottom: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  color: var(--text);
  font-weight: 600;
  text-decoration: none;
}

.list-grid a svg {
  width: 18px;
  height: 18px;
  color: var(--muted);
  flex-shrink: 0;
}

.section-toggle {
  cursor: pointer;
  user-select: none;
}

.section-toggle::after {
  content: '';
  display: inline-block;
  width: 0;
  height: 0;
  margin-left: 4px;
  vertical-align: middle;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid var(--muted);
  transition: transform 180ms ease;
}

.section-toggle.collapsed::after {
  transform: rotate(-90deg);
}

[hidden] {
  display: none !important;
}

@media (max-width: 420px) {
  .shell {
    padding: 12px;
  }

  .title-row {
    flex-wrap: wrap;
  }

  .topbar h1 {
    font-size: 1.42rem;
  }

  .item-row {
    padding: 12px 14px;
  }

  .item-row--pending {
    grid-template-columns: 44px minmax(0, 1fr) 52px;
  }

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

  .edit-form {
    grid-template-columns: minmax(0, 1fr) 70px;
  }
}
