:root {
  --bg: #0b0b0f;
  --surface: #13131a;
  --surface-2: #1a1a24;
  --surface-hover: #20202c;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.14);
  --text: #f3f1ec;
  --text-dim: #9290a0;
  --text-muted: #5f5d6e;
  --ivory: #f0ebe1;
  --ivory-text: #0d0d12;
  --plum: #a855f7;
  --plum-soft: rgba(168, 85, 247, 0.14);
  --sanya: #60a5fa;
  --sanya-soft: rgba(59, 130, 246, 0.14);
  --katya: #f472b6;
  --katya-soft: rgba(236, 72, 153, 0.14);
  --shared: #c084fc;
  --shared-soft: rgba(168, 85, 247, 0.16);
  --success: #34d399;
  --danger: #f87171;
  --radius-lg: 16px;
  --radius-md: 12px;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.45;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.hidden {
  display: none !important;
}

.ambient-glow {
  position: fixed;
  top: -120px;
  left: 50%;
  transform: translateX(-50%);
  width: 480px;
  height: 260px;
  background: radial-gradient(ellipse at center, rgba(139, 92, 246, 0.16) 0%, rgba(236, 72, 153, 0.05) 45%, transparent 72%);
  pointer-events: none;
  z-index: 0;
}

.app {
  position: relative;
  z-index: 1;
  max-width: 560px;
  margin: 0 auto;
  padding: 14px 16px 96px;
}

/* Header */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
}

.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(145deg, #1d1a27, #121118);
  border: 1px solid var(--border-strong);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #d8b4fe;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.brand-kicker {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--text-muted);
  text-transform: uppercase;
}

.header-title {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.user-pill {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dim);
  padding: 5px 10px;
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
}

.archive-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--surface);
  color: var(--text-dim);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.archive-btn.active {
  background: var(--plum-soft);
  border-color: rgba(168, 85, 247, 0.4);
  color: #e9d5ff;
}

/* Editorial Underline Tabs */
.tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border-bottom: 1px solid var(--border);
  margin-bottom: 14px;
}

.tab {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: none;
  background: transparent;
  color: var(--text-dim);
  padding: 10px 6px 12px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: color 0.15s ease;
}

.tab svg {
  opacity: 0.7;
}

.tab.active {
  color: var(--text);
}

.tab.active svg {
  opacity: 1;
  color: #d8b4fe;
}

.tab.active::after {
  content: "";
  position: absolute;
  left: 14%;
  right: 14%;
  bottom: -1px;
  height: 2px;
  border-radius: 2px 2px 0 0;
  background: linear-gradient(90deg, #a855f7, #ec4899);
}

.tab-count {
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  padding: 1px 6px;
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--text-dim);
}

.tab.active .tab-count {
  background: var(--plum-soft);
  color: #e9d5ff;
}

/* Subfilters */
.subfilters {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.pill {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-dim);
  padding: 5px 12px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.pill.active {
  background: var(--ivory);
  color: var(--ivory-text);
  border-color: var(--ivory);
}

/* Cards */
.items-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.card-main {
  display: flex;
  gap: 12px;
  padding: 13px;
}

.card-thumb-wrap {
  position: relative;
  width: 104px;
  height: 70px;
  border-radius: 10px;
  overflow: hidden;
  flex-shrink: 0;
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.card-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.card-body {
  flex: 1;
  min-width: 0;
}

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

.card-badges {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.badge {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--text-dim);
}

.badge-sanya {
  background: var(--sanya-soft);
  color: var(--sanya);
}

.badge-katya {
  background: var(--katya-soft);
  color: var(--katya);
}

.badge-shared {
  background: var(--shared-soft);
  color: var(--shared);
}

.author-tag {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
}

.card-title {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0 0 4px;
  word-break: break-word;
}

.card-title a {
  color: var(--text);
  text-decoration: none;
}

.card-note {
  font-size: 13px;
  color: var(--text-dim);
  margin: 0;
  word-break: break-word;
}

.card-actions {
  display: flex;
  border-top: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.015);
}

.card-btn {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: transparent;
  border: none;
  color: var(--text-dim);
  padding: 9px 10px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s ease;
}

.card-btn:active {
  background: var(--surface-hover);
}

.card-btn + .card-btn {
  border-left: 1px solid var(--border);
}

.card-btn.done {
  color: var(--success);
}

.card-btn.link {
  color: #d8b4fe;
}

.card-btn.delete {
  color: var(--text-muted);
  flex: 0 0 46px;
}

.card-btn.delete:hover {
  color: var(--danger);
}

/* Empty & Loading */
.empty-state {
  margin-top: 24px;
  padding: 40px 20px;
  border-radius: var(--radius-lg);
  border: 1px dashed var(--border-strong);
  background: rgba(19, 19, 26, 0.55);
  text-align: center;
}

.empty-icon {
  width: 48px;
  height: 48px;
  margin: 0 auto 12px;
  border-radius: 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #c084fc;
}

.empty-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
}

.empty-desc {
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 18px;
}

.empty-cta {
  background: var(--ivory);
  color: var(--ivory-text);
  border: none;
  border-radius: 10px;
  padding: 10px 18px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.loading-state {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 48px 16px;
  color: var(--text-dim);
  font-size: 13px;
}

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid var(--border-strong);
  border-top-color: #c084fc;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Bottom Dock CTA */
.bottom-dock {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 12px 16px calc(14px + env(safe-area-inset-bottom, 0px));
  background: linear-gradient(to top, var(--bg) 65%, rgba(11, 11, 15, 0));
  display: flex;
  justify-content: center;
  z-index: 20;
  pointer-events: none;
}

.add-bar-btn {
  pointer-events: auto;
  width: 100%;
  max-width: 528px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 13px 18px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: var(--ivory);
  color: var(--ivory-text);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: -0.01em;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.55);
  cursor: pointer;
  transition: transform 0.1s ease;
}

.add-bar-btn:active {
  transform: scale(0.985);
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(5, 5, 8, 0.72);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 50;
}

.modal-sheet {
  width: 100%;
  max-width: 560px;
  background: #14141c;
  border-top: 1px solid var(--border-strong);
  border-top-left-radius: 22px;
  border-top-right-radius: 22px;
  padding: 10px 18px 26px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-handle {
  width: 38px;
  height: 4px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.15);
  margin: 0 auto 14px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.modal-kicker {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: #c084fc;
  margin-bottom: 2px;
}

.modal-title {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
}

.modal-close {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}

.form {
  display: flex;
  flex-direction: column;
  gap: 13px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dim);
}

.opt {
  font-weight: 400;
  color: var(--text-muted);
}

.input {
  width: 100%;
  padding: 11px 13px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  outline: none;
  color-scheme: dark;
  transition: border-color 0.15s ease;
}

.when-presets {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.preset-chip {
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-dim);
  padding: 5px 10px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.preset-chip.active {
  background: var(--plum-soft);
  border-color: rgba(168, 85, 247, 0.45);
  color: #e9d5ff;
}

.datetime-row {
  display: grid;
  grid-template-columns: 1.35fr 1fr;
  gap: 8px;
}

.input::placeholder {
  color: var(--text-muted);
}

.input:focus {
  border-color: #a855f7;
}

.segmented {
  display: flex;
  gap: 6px;
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 4px;
  border-radius: 12px;
}

.seg-btn {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--text-dim);
  padding: 8px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.seg-btn.active {
  background: var(--surface-2);
  color: var(--text);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.hint {
  font-size: 12px;
  color: #c084fc;
}

.preview-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: 10px;
  background: var(--bg);
  border: 1px solid var(--border);
}

.preview-card img {
  width: 56px;
  height: 38px;
  border-radius: 6px;
  object-fit: cover;
}

.preview-meta {
  font-size: 12px;
  color: var(--text-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.form-error {
  color: var(--danger);
  font-size: 13px;
}

.submit-btn {
  margin-top: 4px;
  width: 100%;
  padding: 13px;
  border-radius: 12px;
  border: none;
  background: var(--ivory);
  color: var(--ivory-text);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}

.submit-btn:disabled {
  opacity: 0.6;
}
