:root {
  color-scheme: dark;
  --bg: #111111;
  --bg-2: #171717;
  --panel: #1c1c1c;
  --panel-2: #222222;
  --panel-3: #292929;
  --text: #f4efe7;
  --muted: #a1978a;
  --border: #343434;
  --border-strong: #474747;
  --accent: #ff7a1a;
  --accent-strong: #ff8f3d;
  --accent-soft: rgba(255, 122, 26, 0.14);
  --success-soft: rgba(107, 165, 115, 0.16);
  --shadow: 0 18px 42px rgba(0, 0, 0, 0.28);
  --radius: 10px;
  --radius-sm: 8px;
  --tap: 48px;
  font-family: "Avenir Next", Avenir, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at top, rgba(255, 122, 26, 0.12), transparent 30%),
    linear-gradient(180deg, var(--bg), var(--bg-2));
  color: var(--text);
}

body {
  min-height: 100vh;
}

button,
input {
  font: inherit;
}

button {
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  min-height: var(--tap);
  padding: 0 0.95rem;
  background: var(--accent);
  color: #140b05;
  font-weight: 700;
  letter-spacing: 0.01em;
}

button:disabled {
  opacity: 0.4;
}

input {
  width: 100%;
  min-height: var(--tap);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0 0.95rem;
  background: #141414;
  color: var(--text);
}

input::placeholder {
  color: #7f786f;
}

.ghost-button,
.icon-button,
.list-name-button {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
}

.app-shell {
  width: min(100%, 760px);
  margin: 0 auto;
  padding: 0;
  padding-top: max(0.65rem, env(safe-area-inset-top));
}

.app-panel {
  min-height: calc(100vh - 1.8rem);
}

.panel {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.02), transparent 22%), var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.8rem;
  box-shadow: var(--shadow);
}

.titlebar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.9rem;
  flex-wrap: nowrap;
}

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

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(1.5rem, 6vw, 2.3rem);
  line-height: 1;
  letter-spacing: -0.03em;
}

h2 {
  font-size: 0.95rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.section-header {
  margin-bottom: 0.75rem;
}

.lists-panel {
  margin-bottom: 0.9rem;
  padding: 0.85rem;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.stack-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.55rem;
  margin-bottom: 0.9rem;
}

.lists,
.items {
  display: grid;
  gap: 0.45rem;
}

.list-card,
.item-row {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.list-card {
  padding: 0.55rem;
}

.list-card.active {
  border-color: var(--accent);
  background: linear-gradient(180deg, rgba(255, 122, 26, 0.08), transparent 80%), var(--panel-2);
}

.list-main,
.item-main {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.list-main {
  width: 100%;
}

.list-name-button {
  flex: 1 1 80%;
  justify-content: flex-start;
  text-align: left;
  padding: 0 0.7rem;
}

.list-meta {
  color: var(--accent-strong);
  font-size: 0.8rem;
  white-space: nowrap;
  margin-left: 0.15rem;
}

.action-cluster {
  display: flex;
  gap: 0.45rem;
  flex-shrink: 0;
}

.icon-button {
  min-width: var(--tap);
  padding: 0;
}

.drag-handle {
  min-width: 34px;
  width: 34px;
  min-height: 34px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--panel-3);
  color: var(--muted);
  font-size: 1.15rem;
  line-height: 1;
  cursor: grab;
  touch-action: none;
}

.drag-handle:active {
  cursor: grabbing;
}

.delete-list-button {
  flex: 0 0 auto;
  margin-left: auto;
}

.items {
  list-style: none;
  padding: 0;
  margin: 0;
}

.item-row {
  padding: 0.45rem 0.55rem;
  transition: background-color 160ms ease, border-color 160ms ease;
}

.item-row.pending-delete {
  opacity: 0.55;
  border-color: #4e6e52;
}

.item-row-ghost {
  opacity: 0.35;
}

.item-row-chosen,
.item-row-drag {
  border-color: var(--accent);
  background: linear-gradient(180deg, rgba(255, 122, 26, 0.08), transparent 100%), var(--panel-3);
}

.item-check {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--accent);
  flex: 0 0 auto;
  transform: translateY(1px);
}

.item-text {
  flex: 1;
  font-size: 1rem;
  line-height: 1.35;
  word-break: break-word;
  padding-left: 0.6rem;
}

.empty-state {
  padding: 0.95rem;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--muted);
  text-align: center;
  background: rgba(255, 255, 255, 0.015);
}

.hidden {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 560px) {
  .titlebar {
    align-items: center;
    flex-direction: row;
  }

  .titlebar .action-cluster {
    width: auto;
  }

  .item-main {
    display: grid;
    grid-template-columns: 16px minmax(0, 1fr) 34px;
    align-items: center;
    column-gap: 0.95rem;
  }

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

@media (min-width: 761px) {
  .app-shell {
    padding: 0;
  }

  .panel {
    padding: 1rem;
  }
}
