:root {
  --page: #f6f1e8;
  --panel: #fffdf8;
  --panel-muted: #eee7dc;
  --text: #1f2320;
  --muted: #716b61;
  --line: #d8d0c3;
  --accent: #2247d8;
  --accent-ink: #ffffff;
  --danger: #b42318;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  font-family: "Aptos", "Segoe UI", system-ui, sans-serif;
  color: var(--text);
  background: var(--page);
  line-height: 1.45;
}

.app-shell {
  display: grid;
  grid-template-columns: 280px 1fr;
  min-height: 100dvh;
}

.sidebar {
  border-right: 1px solid var(--line);
  padding: 1.25rem;
  background: color-mix(in srgb, var(--page) 70%, #ffffff 30%);
}

.brand-block h1 {
  margin: 0;
  font-size: 2rem;
  line-height: 1.1;
}

.brand-block p {
  margin: 0.6rem 0 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.sidebar-section {
  margin-top: 1.25rem;
}

.sidebar-section label,
.field label {
  display: block;
  margin-bottom: 0.45rem;
  font-weight: 600;
  font-size: 0.92rem;
}

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

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 0.55rem;
  padding: 0.65rem 0.72rem;
  color: var(--text);
  background: #ffffff;
}

textarea {
  resize: vertical;
}

input:focus-visible,
textarea:focus-visible,
select:focus-visible,
button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.main-content {
  padding: 1.25rem;
  width: 100%;
}

.main-content > .panel + .panel {
  margin-top: 1rem;
}

.panel {
  max-width: 1180px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 0.85rem;
  padding: 1rem;
  box-shadow: 0 2px 6px rgba(30, 24, 15, 0.05);
}

.panel h2 {
  margin: 0;
  font-size: 1.2rem;
}

.panel-subtext {
  margin: 0.35rem 0 1rem;
  color: var(--muted);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.9rem;
}

.field-span-2 {
  grid-column: span 2;
}

.form-actions {
  margin-top: 1rem;
  display: flex;
  gap: 0.55rem;
}

.button {
  border: 1px solid transparent;
  border-radius: 0.55rem;
  padding: 0.62rem 0.9rem;
  cursor: pointer;
}

.button-primary {
  background: var(--accent);
  color: var(--accent-ink);
}

.button-secondary {
  border-color: var(--line);
  background: var(--panel);
  color: var(--text);
}

.button-inline {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  padding: 0.36rem 0.56rem;
  font-size: 0.9rem;
}

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

.button:hover {
  filter: brightness(0.98);
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
}

.count-pill {
  background: var(--panel-muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.16rem 0.5rem;
  font-size: 0.78rem;
  color: var(--muted);
}

.tag-list {
  margin-top: 0.7rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.tag-filter {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 0.5rem;
  padding: 0.45rem 0.6rem;
  text-align: left;
}

.tag-filter.active {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 8%, #fff 92%);
}

.tag-left {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  min-width: 0;
}

.tag-dot {
  width: 0.62rem;
  height: 0.62rem;
  border-radius: 50%;
  flex: 0 0 auto;
}

.tag-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cards-grid {
  margin-top: 0.9rem;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 0.8rem;
}

.prompt-card {
  border: 1px solid var(--line);
  border-radius: 0.75rem;
  background: #fff;
  padding: 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.72rem;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}

.ai-badge {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.2rem 0.48rem;
  font-size: 0.78rem;
  color: var(--muted);
}

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

.card-title {
  margin: 0;
  font-size: 1.05rem;
  line-height: 1.25;
}

.prompt-body {
  margin: 0;
  padding: 0.72rem;
  border: 1px solid var(--line);
  border-radius: 0.6rem;
  background: color-mix(in srgb, var(--page) 45%, #fff 55%);
  white-space: pre-wrap;
  word-break: break-word;
}

.tag-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.18rem 0.52rem;
  font-size: 0.78rem;
}

.card-notes {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
  white-space: pre-wrap;
}

.card-actions {
  display: flex;
  gap: 0.45rem;
}

.form-errors {
  display: none;
  margin-bottom: 0.8rem;
  padding: 0.62rem;
  border: 1px solid color-mix(in srgb, var(--danger) 35%, #fff 65%);
  background: color-mix(in srgb, var(--danger) 8%, #fff 92%);
  color: #7f1f16;
  border-radius: 0.5rem;
}

.form-errors.visible {
  display: block;
}

.empty-state {
  margin-top: 0.9rem;
  border: 1px dashed var(--line);
  border-radius: 0.7rem;
  padding: 1.1rem;
  color: var(--muted);
  background: color-mix(in srgb, var(--panel) 70%, var(--page) 30%);
}

.hidden {
  display: none !important;
}

@media (max-width: 800px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .tag-list {
    flex-direction: row;
    overflow-x: auto;
    padding-bottom: 0.2rem;
  }

  .tag-filter {
    min-width: 180px;
  }

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

  .field-span-2 {
    grid-column: span 1;
  }

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