:root {
  --bg-deep: #05070a;
  --bg-page: #0a0e14;
  --bg-surface: #111821;
  --bg-surface-raised: rgba(17, 24, 33, 0.72);
  --bg-surface-hover: #18202b;
  --bg-input: #0d131b;
  --border: rgba(148, 163, 184, 0.12);
  --border-strong: rgba(148, 163, 184, 0.2);
  --text: #e2e8f0;
  --text-soft: #94a3b8;
  --muted: #64748b;
  --cyan: #00d9ff;
  --cyan-soft: rgba(0, 217, 255, 0.12);
  --cyan-glow: rgba(0, 217, 255, 0.35);
  --amber: #ffb84d;
  --amber-soft: rgba(255, 184, 77, 0.12);
  --amber-glow: rgba(255, 184, 77, 0.35);
  --gold: #fbbf24;
  --gold-soft: rgba(251, 191, 36, 0.14);
  --gold-glow: rgba(251, 191, 36, 0.35);
  --focus-ring: rgba(0, 217, 255, 0.55);
  --primary: #00d9ff;
  --primary-strong: #33e1ff;
  --primary-soft: rgba(0, 217, 255, 0.15);
  --red: #ff6b6b;
  --red-soft: rgba(255, 107, 107, 0.12);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 14px 40px rgba(0, 0, 0, 0.5);
  --radius: 12px;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--bg-deep);
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background: var(--bg-page);
  font-family: "Bricolage Grotesque", system-ui, -apple-system, sans-serif;
  font-optical-sizing: auto;
  line-height: 1.45;
  overflow-x: hidden;
}

::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 999px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-soft);
}

/* Ambient background effects */
.ambient {
  position: fixed;
  border-radius: 50%;
  filter: blur(100px);
  opacity: 0.18;
  pointer-events: none;
  z-index: 0;
}

.ambient-1 {
  top: -10%;
  left: -5%;
  width: 50vw;
  height: 50vw;
  background: var(--cyan);
  animation: ambientDrift 20s ease-in-out infinite alternate;
}

.ambient-2 {
  bottom: -10%;
  right: -5%;
  width: 45vw;
  height: 45vw;
  background: var(--amber);
  animation: ambientDrift 25s ease-in-out infinite alternate-reverse;
}

@keyframes ambientDrift {
  from {
    transform: translate(0, 0) scale(1);
  }
  to {
    transform: translate(30px, 50px) scale(1.1);
  }
}

.noise {
  position: fixed;
  inset: 0;
  opacity: 0.035;
  pointer-events: none;
  z-index: 1;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-repeat: repeat;
  background-size: 256px 256px;
}

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

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

/* App shell */
.app-shell {
  position: relative;
  z-index: 2;
  width: min(1280px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 24px 0 48px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
}

/* Header */
.app-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 22px 24px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--bg-surface-raised);
  box-shadow: var(--shadow-md);
  backdrop-filter: blur(24px);
  animation: fadeInDown 600ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

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

.logo-mark {
  flex-shrink: 0;
  filter: drop-shadow(0 0 16px rgba(0, 217, 255, 0.25));
  transition: transform 300ms ease;
}

.app-header:hover .logo-mark {
  transform: rotate(-4deg) scale(1.05);
}

.eyebrow {
  margin-bottom: 4px;
  color: var(--cyan);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1 {
  color: #f8fafc;
  font-size: 2.2rem;
  line-height: 1;
  font-weight: 800;
  letter-spacing: -0.02em;
}

h2 {
  color: #f1f5f9;
  font-size: 1.1rem;
  line-height: 1.25;
  font-weight: 700;
}

h3 {
  color: #f1f5f9;
  font-size: 1rem;
  line-height: 1.35;
  font-weight: 700;
}

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

.summary .status-chip {
  display: inline-flex;
  min-height: 36px;
  align-items: center;
  border-radius: 999px;
  padding: 0 14px;
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-soft);
  font-size: 0.82rem;
  font-weight: 700;
  backdrop-filter: blur(8px);
}

/* Panels */
.panel {
  position: relative;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--bg-surface-raised);
  box-shadow: var(--shadow-md);
  backdrop-filter: blur(24px);
  overflow: hidden;
}

.panel-form {
  animation: fadeInUp 600ms cubic-bezier(0.16, 1, 0.3, 1) 100ms both;
}

.panel-list {
  animation: fadeInUp 600ms cubic-bezier(0.16, 1, 0.3, 1) 200ms both;
}

.section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
}

.panel-list .section-head {
  padding: 22px 22px 0;
}

.panel-form .form-toggle {
  width: 100%;
  margin: 0;
  padding: 18px 22px;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  transition: background 180ms ease;
}

.panel-form .form-toggle:hover {
  background: rgba(255, 255, 255, 0.02);
}

.form-toggle-text h2 {
  margin: 0;
}

.form-toggle-text p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.88rem;
}

.chevron {
  display: inline-flex;
  width: 36px;
  height: 36px;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--text-soft);
  transition: transform 250ms cubic-bezier(0.16, 1, 0.3, 1), color 180ms ease, border-color 180ms ease;
}

.panel-form .form-toggle[aria-expanded="true"] .chevron {
  transform: rotate(180deg);
  color: var(--cyan);
  border-color: var(--cyan);
}

.form-body {
  display: grid;
  grid-template-rows: 1fr;
  transition: grid-template-rows 320ms cubic-bezier(0.16, 1, 0.3, 1);
}

.form-body > form {
  min-height: 0;
  padding: 0 22px 22px;
  overflow: hidden;
}

.panel-form.is-collapsed .form-body {
  grid-template-rows: 0fr;
}

.panel-form.is-collapsed .form-body > form {
  padding-top: 0;
  padding-bottom: 0;
  visibility: hidden;
}

.section-head p {
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.5;
}

/* Form fields */
.field,
.search-field,
.filter-field {
  display: grid;
  gap: 8px;
}

.field + .field,
.field-grid + .field {
  margin-top: 16px;
}

.field-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.ai-suggest-controls {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.ai-status {
  font-size: 0.75rem;
  color: var(--text-soft);
  min-height: 1em;
}

.ai-status.is-error {
  color: #e05a5a;
}

.ai-status.is-loading::after {
  content: "";
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-left: 6px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  vertical-align: middle;
  animation: ai-spin 0.8s linear infinite;
}

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

.btn-sm {
  padding: 4px 10px;
  font-size: 0.78rem;
  border-radius: 8px;
}

.btn-sm:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.field-grid {
  display: grid;
  gap: 16px;
  margin-top: 16px;
}

label,
.search-field span,
.filter-field span {
  color: var(--text-soft);
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.04em;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--bg-input);
  color: var(--text);
  padding: 0.82rem 0.92rem;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.3);
  transition: border-color 180ms ease, box-shadow 180ms ease, background 180ms ease;
  outline: none;
}

input::placeholder,
textarea::placeholder {
  color: #64748b;
  opacity: 1;
}

textarea,
.entry-content {
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  white-space: pre-wrap;
}

textarea {
  min-height: 220px;
  resize: vertical;
  line-height: 1.6;
  font-size: 0.88rem;
}

#description {
  min-height: 80px;
  font-family: "Bricolage Grotesque", system-ui, -apple-system, sans-serif;
  white-space: pre-wrap;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 3px var(--cyan-soft), inset 0 1px 2px rgba(0, 0, 0, 0.3);
}

select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

/* Actions */
.actions,
.toolbar,
.entry-head,
.entry-footer,
.card-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.actions {
  justify-content: flex-end;
  margin-top: 18px;
}

.toolbar {
  align-items: end;
  padding: 20px;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.02);
}

.search-field {
  flex: 1;
}

.filter-field {
  width: min(100%, 400px);
}

/* Segmented control */
.segmented-control {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  gap: 6px;
  min-height: 48px;
  padding: 6px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--bg-input);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.4);
}

.segment {
  min-width: 0;
  min-height: 36px;
  border: 0;
  border-radius: 999px;
  padding: 0 14px;
  cursor: pointer;
  overflow: hidden;
  background: transparent;
  color: var(--text-soft);
  font-weight: 800;
  font-size: 0.86rem;
  line-height: 1;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: background 180ms ease, color 180ms ease, box-shadow 180ms ease, transform 180ms ease;
}

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

.segment.is-active {
  background: linear-gradient(135deg, var(--cyan), var(--primary-strong));
  color: var(--bg-deep);
  box-shadow: 0 4px 16px var(--cyan-glow);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: 0.68rem 1.1rem;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  font-weight: 800;
  font-size: 0.88rem;
  line-height: 1;
  transition: transform 150ms ease, box-shadow 150ms ease, background 150ms ease, border-color 150ms ease;
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.btn:disabled {
  cursor: wait;
  opacity: 0.5;
  transform: none;
  box-shadow: none;
}

.btn-primary {
  background: linear-gradient(135deg, var(--cyan), var(--primary-strong));
  color: var(--bg-deep);
  border-color: transparent;
  box-shadow: 0 4px 16px var(--cyan-glow);
}

.btn-primary:hover {
  background: linear-gradient(135deg, var(--primary-strong), #66e8ff);
  box-shadow: 0 6px 24px var(--cyan-glow);
}

.btn-ghost {
  border-color: var(--border-strong);
  background: transparent;
  color: var(--text-soft);
}

.btn-ghost:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  border-color: var(--text-soft);
}

.btn-danger {
  background: var(--red-soft);
  color: var(--red);
  border-color: rgba(255, 107, 107, 0.2);
}

.btn-danger:hover {
  background: rgba(255, 107, 107, 0.18);
  box-shadow: 0 4px 16px rgba(255, 107, 107, 0.15);
}

.btn-small {
  min-height: 34px;
  padding: 0.48rem 0.72rem;
  font-size: 0.82rem;
}

.btn-icon {
  display: inline-flex;
  flex-shrink: 0;
}

.category-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.01);
  min-height: 0;
}

.category-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 30px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: transparent;
  color: var(--text-soft);
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 150ms ease, color 150ms ease, border-color 150ms ease, box-shadow 150ms ease;
}

.category-chip:hover {
  border-color: var(--text-soft);
  color: var(--text);
}

.category-chip.is-active {
  background: linear-gradient(135deg, var(--cyan), var(--primary-strong));
  color: var(--bg-deep);
  border-color: transparent;
  box-shadow: 0 4px 12px var(--cyan-glow);
}

.entry-category {
  display: inline-flex;
  min-height: 28px;
  flex: 0 0 auto;
  align-items: center;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  padding: 0 12px;
  font-size: 0.76rem;
  font-weight: 800;
  color: var(--text-soft);
  background: rgba(255, 255, 255, 0.03);
}

/* Entries */
.entries {
  display: grid;
  gap: 14px;
  padding: 20px;
}

.entry-card,
.empty-state {
  position: relative;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--bg-surface);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.entry-card {
  padding: 18px;
  transition: transform 220ms ease, box-shadow 220ms ease, border-color 220ms ease;
  animation: cardEnter 400ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

.entry-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
  border-color: var(--border-strong);
}

.entry-glow {
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity 300ms ease;
  pointer-events: none;
}

.entry-card:hover .entry-glow {
  opacity: 1;
}

.entry-card[data-kind="cli"] .entry-glow {
  background: radial-gradient(600px circle at 80% 20%, var(--amber-soft), transparent 60%);
}

.entry-card[data-kind="prompt"] .entry-glow {
  background: radial-gradient(600px circle at 80% 20%, var(--cyan-soft), transparent 60%);
}

.entry-card::before {
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  content: "";
  border-radius: 0 2px 2px 0;
}

.entry-card[data-kind="cli"]::before {
  background: linear-gradient(180deg, var(--amber), #ff9f1c);
  box-shadow: 0 0 12px var(--amber-glow);
}

.entry-card[data-kind="prompt"]::before {
  background: linear-gradient(180deg, var(--cyan), #00a8cc);
  box-shadow: 0 0 12px var(--cyan-glow);
}

.entry-head {
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
}

.entry-meta {
  min-width: 0;
}

.entry-badges {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.favorite-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  padding: 0;
  transition: color 180ms ease, border-color 180ms ease, background 180ms ease, transform 150ms ease;
}

.favorite-btn:hover {
  color: var(--gold);
  border-color: var(--gold);
  transform: scale(1.1);
}

.favorite-btn.is-active {
  background: var(--gold-soft);
  border-color: var(--gold);
  color: var(--gold);
}

.favorite-btn.is-active .favorite-icon {
  fill: currentColor;
}

.favorite-filter-btn {
  flex-shrink: 0;
}

.favorite-filter-btn.is-active {
  background: var(--gold-soft);
  border-color: var(--gold);
  color: var(--gold);
  box-shadow: 0 4px 12px var(--gold-glow);
}

.duplicate-filter-btn.is-active {
  background: var(--red-soft);
  border-color: rgba(255, 107, 107, 0.35);
  color: var(--red);
}

.entry-title {
  overflow-wrap: anywhere;
  color: #f8fafc;
  font-weight: 700;
}

.entry-kind {
  display: inline-flex;
  min-height: 28px;
  flex: 0 0 auto;
  align-items: center;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 0 12px;
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.entry-kind[data-kind="cli"] {
  border-color: rgba(255, 184, 77, 0.25);
  background: var(--amber-soft);
  color: var(--amber);
}

.entry-kind[data-kind="prompt"] {
  border-color: rgba(0, 217, 255, 0.25);
  background: var(--cyan-soft);
  color: var(--cyan);
}

.entry-description {
  min-height: 0;
  margin-top: 4px;
  color: var(--text-soft);
  font-size: 0.86rem;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.entry-tags {
  min-height: 20px;
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.82rem;
  overflow-wrap: anywhere;
}

.entry-content {
  max-height: 280px;
  margin: 14px 0;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg-deep);
  color: #cbd5e1;
  padding: 14px;
  font-size: 0.84rem;
  line-height: 1.65;
}

.entry-date {
  color: var(--muted);
  font-size: 0.78rem;
}

.card-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.empty-state {
  display: grid;
  min-height: 260px;
  place-items: center;
  padding: 32px;
  text-align: center;
  color: var(--muted);
}

.empty-state strong {
  display: block;
  margin-bottom: 8px;
  color: var(--text-soft);
  font-size: 1.05rem;
  font-weight: 700;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(120%);
  z-index: 100;
  padding: 12px 24px;
  border-radius: 999px;
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  color: var(--text);
  font-weight: 700;
  font-size: 0.88rem;
  box-shadow: var(--shadow-md);
  backdrop-filter: blur(16px);
  opacity: 0;
  transition: transform 400ms cubic-bezier(0.16, 1, 0.3, 1), opacity 300ms ease;
  pointer-events: none;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* Modal */
.modal-root[hidden] {
  display: none;
}

.modal-root {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  place-items: center;
  padding: 20px;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(5, 7, 10, 0.72);
  backdrop-filter: blur(6px);
  animation: fadeIn 180ms ease both;
}

.modal-dialog {
  position: relative;
  width: min(440px, 100%);
  border: 1px solid var(--border-strong);
  border-radius: 20px;
  background: var(--bg-surface-raised);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(24px);
  padding: 26px;
  outline: none;
  animation: modalEnter 220ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

.modal-title {
  margin-bottom: 8px;
  color: #f8fafc;
  font-size: 1.15rem;
  font-weight: 800;
}

.modal-title:empty {
  display: none;
}

.modal-message {
  color: var(--text-soft);
  font-size: 0.92rem;
  line-height: 1.55;
}

.modal-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 22px;
}

.modal-actions .btn[hidden] {
  display: none;
}

.modal-dialog.is-danger .btn[data-modal-action="confirm"] {
  background: var(--red);
  color: #fff;
  box-shadow: 0 4px 16px rgba(255, 107, 107, 0.35);
}

.modal-dialog.is-danger .btn[data-modal-action="confirm"]:hover {
  background: #ff4f4f;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes modalEnter {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Animations */
@keyframes fadeInDown {
  from {
    opacity: 0;
    transform: translateY(-12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes cardEnter {
  from {
    opacity: 0;
    transform: translateY(16px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Category multi-select */
.category-input-wrap {
  position: relative;
  display: grid;
  gap: 8px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--bg-input);
  padding: 0.6rem 0.8rem;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.3);
  transition: border-color 180ms ease, box-shadow 180ms ease;
}

.category-input-wrap:focus-within {
  border-color: var(--cyan);
  box-shadow: 0 0 0 3px var(--cyan-soft), inset 0 1px 2px rgba(0, 0, 0, 0.3);
}

.category-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 0;
}

.category-chip-form {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 28px;
  padding: 0 8px 0 12px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--cyan-soft);
  color: var(--cyan);
  font-size: 0.82rem;
  font-weight: 700;
}

.category-chip-remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: inherit;
  cursor: pointer;
  padding: 0;
  font-size: 1rem;
  line-height: 1;
  transition: background 150ms ease;
}

.category-chip-remove:hover {
  background: rgba(0, 217, 255, 0.2);
}

.category-search {
  width: 100%;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--text);
  padding: 0.2rem 0;
  font-size: 0.88rem;
  outline: none;
}

.category-search::placeholder {
  color: #64748b;
  opacity: 1;
}

.category-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 50;
  margin: 0;
  padding: 6px;
  list-style: none;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--bg-surface);
  box-shadow: var(--shadow-md);
  max-height: 200px;
  overflow: auto;
}

.category-dropdown[hidden] {
  display: none;
}

.category-dropdown-item {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 0 12px;
  border-radius: 8px;
  cursor: pointer;
  color: var(--text-soft);
  font-size: 0.86rem;
  font-weight: 700;
  transition: background 150ms ease, color 150ms ease;
}

.category-dropdown-item:hover,
.category-dropdown-item.is-active {
  background: var(--bg-surface-hover);
  color: var(--text);
}

/* Responsive */
@media (max-width: 720px) {
  .app-shell {
    width: min(100% - 20px, 1280px);
    padding-top: 14px;
  }

  .app-header,
  .toolbar,
  .entry-footer,
  .actions {
    align-items: stretch;
    flex-direction: column;
  }

  .header-brand {
    width: 100%;
  }

  .summary {
    justify-content: flex-start;
    width: 100%;
  }

  .toolbar {
    padding: 16px;
    gap: 14px;
  }

  .filter-field {
    width: 100%;
  }

  .segmented-control {
    min-height: 46px;
  }

  .segment {
    padding: 0 8px;
    font-size: 0.84rem;
  }

  .entries {
    padding: 16px;
  }

  .card-actions,
  .card-actions .btn,
  .actions .btn {
    width: 100%;
  }

  h1 {
    font-size: 1.8rem;
  }
}

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

@media (min-width: 1020px) {
  /* Lookup-Mode: single column, list is hero, form is a collapsible top-section */
  .app-shell {
    grid-template-columns: 1fr;
    align-items: start;
  }

  .panel-form .form-toggle {
    padding: 22px 26px;
  }

  .form-body > form {
    padding: 0 26px 26px;
  }
}

/* Keyboard focus — visible ring for all interactive elements */
.btn:focus-visible,
.segment:focus-visible,
.category-chip:focus-visible,
.favorite-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--bg-deep), 0 0 0 4px var(--focus-ring);
}

.btn-primary:focus-visible,
.segment.is-active:focus-visible,
.category-chip.is-active:focus-visible {
  box-shadow: 0 4px 16px var(--cyan-glow), 0 0 0 2px var(--bg-deep), 0 0 0 4px var(--focus-ring);
}

/* Respect user motion preferences */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }

  .ambient-1,
  .ambient-2 {
    animation: none !important;
  }
}
