:root {
  --bg: #fff8fb;
  --bg-mid: #f7fbff;
  --bg-end: #fff;
  --surface: #ffffff;
  --panel: rgba(255, 255, 255, 0.9);
  --panel-soft: rgba(255, 255, 255, 0.88);
  --control: #ffffff;
  --surface-strong: #fff0f6;
  --ink: #222533;
  --muted: #707487;
  --line: #eadde5;
  --rose: #e94f8d;
  --rose-dark: #bf2e68;
  --mint: #2f9f8f;
  --mint-soft: #dff6ef;
  --blue: #5966dc;
  --blue-soft: #e8ebff;
  --gold: #f4ba3f;
  --danger: #d94b4b;
  --danger-soft: #ffe3e3;
  --notice-bg: #fff8e7;
  --notice-line: #f0d08d;
  --notice-ink: #7c5512;
  --location-soft: #fff2d2;
  --location-ink: #765015;
  --placeholder-bg: linear-gradient(135deg, #fbe3ee, #e8f5ff);
  --active-control: #222533;
  --active-control-ink: #ffffff;
  --brand-mark-bg: #222533;
  --brand-mark-ink: #ffffff;
  --archive-bg: #f0edf2;
  --archive-ink: #5f5564;
  --shadow: 0 18px 50px rgba(58, 37, 48, 0.12);
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

:root[data-theme="dark"] {
  --bg: #121018;
  --bg-mid: #171b2a;
  --bg-end: #0f1219;
  --surface: #1b1f2b;
  --panel: rgba(27, 31, 43, 0.92);
  --panel-soft: rgba(27, 31, 43, 0.88);
  --control: #151822;
  --surface-strong: #261a2a;
  --ink: #f7eff6;
  --muted: #aaa4b5;
  --line: #3a3345;
  --rose: #ff6fa9;
  --rose-dark: #ff9ac4;
  --mint: #4cc1ae;
  --mint-soft: #173c37;
  --blue: #8f9bff;
  --blue-soft: #222b56;
  --gold: #ffd36a;
  --danger: #ff7777;
  --danger-soft: #3b2028;
  --notice-bg: #2d2616;
  --notice-line: #604f26;
  --notice-ink: #f4d996;
  --location-soft: #332a18;
  --location-ink: #f2cc72;
  --placeholder-bg: linear-gradient(135deg, #372033, #172a38);
  --active-control: #f4d7e7;
  --active-control-ink: #211823;
  --brand-mark-bg: #f7eff6;
  --brand-mark-ink: #211823;
  --archive-bg: #2f2935;
  --archive-ink: #d8cfdd;
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  background: linear-gradient(180deg, var(--bg) 0%, var(--bg-mid) 52%, var(--bg-end) 100%);
  color: var(--ink);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

a {
  color: inherit;
}

.is-hidden {
  display: none !important;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-panel {
  width: min(500px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 28px;
  box-shadow: var(--shadow);
}

.login-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.brand-lockup.compact {
  gap: 10px;
}

.brand-lockup > div {
  min-width: 0;
}

.brand-mark {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 8px;
  background: var(--brand-mark-bg);
  color: var(--brand-mark-ink);
  font-weight: 900;
  font-size: 1.35rem;
}

.brand-lockup.compact .brand-mark {
  width: 40px;
  height: 40px;
}

.eyebrow {
  margin: 0 0 2px;
  color: var(--rose-dark);
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(1.75rem, 3.4vw, 2rem);
  line-height: 1.02;
  white-space: nowrap;
}

h2,
h3 {
  margin-bottom: 0;
  line-height: 1.1;
}

.login-form,
.item-form {
  display: grid;
  gap: 16px;
  margin-top: 28px;
}

.profile-switch,
.app-tabs {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.profile-choice,
.tab-button {
  min-height: 42px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
}

.profile-choice.is-selected,
.tab-button.is-active {
  background: var(--active-control);
  color: var(--active-control-ink);
}

.field {
  display: grid;
  gap: 7px;
  min-width: 0;
}

.field span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

input,
select,
textarea {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--control);
  color: var(--ink);
  outline: none;
  padding: 11px 12px;
}

textarea {
  resize: vertical;
  min-height: 86px;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(89, 102, 220, 0.14);
}

.primary-button,
.secondary-button,
.ghost-button,
.danger-button,
.icon-button {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  padding: 0 16px;
  font-weight: 900;
}

.primary-button {
  background: var(--rose);
  color: #fff;
}

.primary-button:hover {
  background: var(--rose-dark);
}

.secondary-button {
  background: var(--blue-soft);
  color: var(--blue);
}

.ghost-button {
  background: var(--control);
  border: 1px solid var(--line);
  color: var(--ink);
}

.danger-button {
  background: var(--danger-soft);
  color: var(--danger);
}

.icon-button {
  width: 40px;
  padding: 0;
  background: var(--control);
  border: 1px solid var(--line);
  color: var(--muted);
}

.theme-toggle {
  display: inline-grid;
  place-items: center;
  width: 42px;
  min-width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--control);
  color: var(--ink);
  padding: 0;
}

.theme-toggle:hover {
  border-color: var(--blue);
}

.theme-icon {
  position: relative;
  display: block;
  width: 18px;
  height: 18px;
  border: 2px solid currentColor;
  border-radius: 50%;
}

.theme-icon::after {
  content: "";
  position: absolute;
  width: 10px;
  height: 18px;
  top: -2px;
  left: 7px;
  border-radius: 50%;
  background: var(--control);
  opacity: 0;
  transition: opacity 0.16s ease;
}

:root[data-theme="dark"] .theme-icon::after {
  opacity: 1;
}

.form-error {
  min-height: 20px;
  margin: 0;
  color: var(--danger);
  font-weight: 700;
}

.app-shell {
  width: min(1180px, calc(100% - 28px));
  margin: 0 auto;
  padding: 22px 0 34px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 0 18px;
}

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

.profile-badge {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  background: var(--mint-soft);
  color: var(--mint);
  font-size: 0.86rem;
  font-weight: 900;
}

.app-tabs {
  grid-template-columns: repeat(3, 1fr);
  position: sticky;
  top: 0;
  z-index: 5;
  margin-bottom: 16px;
  box-shadow: 0 10px 24px rgba(48, 42, 56, 0.06);
}

.recap-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
  padding: 14px 16px;
  border: 1px solid #f0c7d9;
  border-radius: 8px;
  background: var(--surface-strong);
}

.recap-banner div {
  display: grid;
  gap: 2px;
}

.recap-banner span {
  color: var(--muted);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(280px, 360px) 1fr;
  gap: 18px;
  align-items: start;
}

.workspace.is-full-width {
  grid-template-columns: 1fr;
}

.workspace.is-full-width .list-panel,
.editor-panel.is-hidden + .list-panel {
  grid-column: 1 / -1;
}

.editor-panel,
.list-panel {
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.editor-panel {
  position: sticky;
  top: 90px;
  padding: 18px;
}

.panel-heading,
.list-heading {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 14px;
}

.input-action {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.form-grid.single-grow {
  grid-template-columns: 1fr;
}

.notice {
  border: 1px solid var(--notice-line);
  border-radius: 8px;
  background: var(--notice-bg);
  color: var(--notice-ink);
  padding: 10px 12px;
  font-weight: 700;
}

.list-panel {
  min-height: 580px;
  padding: 18px;
}

.stats-line {
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 800;
  text-align: right;
}

.filters {
  display: grid;
  grid-template-columns: minmax(180px, 1.4fr) repeat(3, minmax(120px, 1fr)) repeat(2, minmax(88px, 0.7fr)) minmax(132px, auto);
  gap: 10px;
  align-items: end;
  margin: 18px 0;
}

.archive-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--control);
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 900;
}

.archive-toggle input {
  width: 18px;
  min-height: 18px;
  accent-color: var(--rose);
}

.items-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}

.item-card {
  display: grid;
  grid-template-rows: 170px auto;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  min-width: 0;
}

.item-card.is-archived {
  opacity: 0.72;
}

.item-image {
  position: relative;
  background: var(--placeholder-bg);
  overflow: hidden;
}

.item-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.item-placeholder {
  display: grid;
  place-items: center;
  height: 100%;
  color: var(--rose-dark);
  font-size: 2rem;
  font-weight: 900;
}

.item-body {
  display: grid;
  gap: 10px;
  padding: 13px;
}

.item-title {
  color: var(--ink);
  font-weight: 900;
  line-height: 1.18;
  text-decoration: none;
  overflow-wrap: anywhere;
}

.item-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  align-items: center;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 9px;
  border-radius: 999px;
  background: var(--blue-soft);
  color: var(--blue);
  font-size: 0.76rem;
  font-weight: 900;
}

.pill.price {
  background: var(--mint-soft);
  color: var(--mint);
}

.pill.archive {
  background: var(--archive-bg);
  color: var(--archive-ink);
}

.pill.location {
  background: var(--location-soft);
  color: var(--location-ink);
}

.item-note,
.item-date {
  margin: 0;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.35;
}

.item-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.item-actions a,
.item-actions button {
  min-height: 36px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--control);
  color: var(--ink);
  padding: 0 11px;
  font-size: 0.84rem;
  font-weight: 900;
  text-decoration: none;
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 300px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
  padding: 28px;
}

.empty-state strong {
  color: var(--ink);
  display: block;
  margin-bottom: 6px;
}

.recap-view {
  display: grid;
  justify-items: center;
  gap: 18px;
  padding: 24px 0 50px;
}

.recap-copy {
  text-align: center;
  max-width: 620px;
}

.recap-copy p:last-child {
  color: var(--muted);
}

.recap-deck {
  width: min(420px, 100%);
  min-height: 560px;
  display: grid;
  place-items: center;
}

.recap-card {
  width: 100%;
  min-height: 540px;
  display: grid;
  grid-template-rows: 300px auto;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  touch-action: pan-y;
  user-select: none;
}

.recap-card .item-body {
  align-content: start;
}

.recap-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  width: min(420px, 100%);
}

.recap-actions button {
  min-height: 52px;
}

@media (max-width: 920px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .editor-panel {
    position: static;
  }

  .filters {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .search-field {
    grid-column: 1 / -1;
  }
}

@media (max-width: 620px) {
  .app-shell {
    width: min(100% - 20px, 1180px);
    padding-top: 10px;
  }

  .topbar {
    align-items: flex-start;
  }

  .login-heading {
    gap: 12px;
  }

  .login-panel .brand-lockup {
    gap: 10px;
  }

  .login-panel .brand-mark {
    width: 40px;
    height: 40px;
    font-size: 1.2rem;
  }

  h1 {
    font-size: clamp(1.55rem, 7vw, 1.85rem);
  }

  .topbar-actions {
    flex-direction: column;
    align-items: flex-end;
  }

  .brand-lockup.compact .brand-mark {
    display: none;
  }

  .app-tabs {
    bottom: 10px;
    top: auto;
    position: fixed;
    left: 10px;
    right: 10px;
    z-index: 20;
    margin-bottom: 0;
  }

  .workspace,
  .recap-view {
    padding-bottom: 84px;
  }

  .login-panel,
  .editor-panel,
  .list-panel {
    padding: 16px;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .filters {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .search-field,
  .archive-toggle {
    grid-column: 1 / -1;
  }

  .items-grid {
    grid-template-columns: 1fr;
  }

  .item-card {
    grid-template-rows: 210px auto;
  }

  .recap-card {
    min-height: 500px;
    grid-template-rows: 270px auto;
  }

  .recap-deck {
    min-height: 520px;
  }
}

@media (max-width: 420px) {
  .login-panel .brand-mark {
    display: none;
  }

  h1 {
    font-size: clamp(1.45rem, 7vw, 1.7rem);
  }
}
