:root {
  color-scheme: light;
  --ink: #202124;
  --muted: #626873;
  --line: #d9dde3;
  --panel: #ffffff;
  --surface: #f5f2ed;
  --accent: #176b87;
  --accent-strong: #0e4f66;
  --accent-soft: #dff0f4;
  --warm: #b8692f;
  --success: #2f7d54;
  --danger: #a54432;
  --shadow: 0 14px 40px rgba(32, 33, 36, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--surface);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

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

.app-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 16px clamp(14px, 4vw, 42px);
  background: #ffffff;
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 0.7rem;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1 {
  margin-bottom: 4px;
  font-size: clamp(1.75rem, 6vw, 2.55rem);
  line-height: 1;
}

h2 {
  margin-bottom: 0;
  font-size: 1.1rem;
}

h3 {
  margin-bottom: 6px;
  font-size: 1rem;
}

.header-subtitle {
  max-width: 660px;
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.35;
}

.header-actions,
.section-heading,
.toolbar,
.field-grid,
.admin-actions,
.card-actions {
  display: flex;
  gap: 10px;
}

.header-actions {
  flex-shrink: 0;
}

.section-heading {
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(320px, 0.85fr) minmax(360px, 1.15fr);
  gap: 18px;
  width: min(1220px, 100%);
  margin: 0 auto;
  padding: 18px clamp(12px, 4vw, 42px) 40px;
}

.capture-panel,
.review-panel,
.admin-panel {
  min-width: 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: clamp(14px, 3vw, 22px);
}

.project-context {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 700;
}

.quick-capture-grid {
  display: grid;
  grid-template-columns: 0.78fr 1.22fr;
  gap: 10px;
}

.capture-icon-card {
  display: grid;
  align-content: start;
  gap: 5px;
  min-height: 132px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #ffffff;
  color: var(--ink);
  padding: 12px;
}

.capture-icon-card:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.capture-icon-card span:not(.capture-icon) {
  font-size: 0.95rem;
  font-weight: 850;
}

.capture-icon-card small,
.file-status {
  color: var(--muted);
  line-height: 1.25;
}

.capture-icon {
  font-size: 1.75rem;
}

.capture-icon-card input[type="file"] {
  min-height: 42px;
  padding: 8px;
}

.note-card textarea {
  min-height: 66px;
  margin-top: 2px;
}

.intel-form,
.admin-form {
  display: grid;
  gap: 12px;
}

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

label,
fieldset {
  display: grid;
  gap: 7px;
  min-width: 0;
  margin: 0;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 760;
}

fieldset {
  border: 0;
  padding: 0;
}

legend {
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 760;
}

.optional {
  color: #8a9099;
  font-weight: 600;
}

input,
select,
textarea {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #ffffff;
  color: var(--ink);
  padding: 11px 12px;
}

textarea {
  resize: vertical;
  line-height: 1.4;
}

input:focus,
select:focus,
textarea:focus,
button:focus-visible {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
  outline: none;
}

.chip-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  max-height: 164px;
  overflow: auto;
  padding-bottom: 2px;
}

.chip {
  position: relative;
}

.chip input {
  position: absolute;
  inset: 0;
  opacity: 0;
}

.chip span {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #ffffff;
  color: var(--ink);
  padding: 7px 11px;
  font-size: 0.82rem;
  font-weight: 750;
}

.chip input:checked + span {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.primary-button,
.secondary-button,
.small-button,
.icon-only-button,
.text-button,
.card-actions button {
  min-height: 44px;
  border-radius: 12px;
  border: 1px solid transparent;
  font-weight: 850;
}

.primary-button {
  width: 100%;
  background: var(--accent);
  color: #ffffff;
  padding: 0 18px;
}

.primary-button:hover {
  background: var(--accent-strong);
}

.secondary-button,
.small-button,
.icon-only-button,
.card-actions button {
  background: #ffffff;
  border-color: var(--line);
  color: var(--ink);
  padding: 0 13px;
}

.icon-only-button {
  width: 44px;
  padding: 0;
  font-size: 1.1rem;
}

.text-button {
  min-height: 36px;
  background: transparent;
  color: var(--danger);
  padding: 0 4px;
}

.count-pill,
.status-badge {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  min-height: 28px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 0.76rem;
  font-weight: 850;
  padding: 4px 10px;
  white-space: nowrap;
}

.status-badge.reviewed {
  background: #e6f3ec;
  color: var(--success);
}

.status-badge.duplicate,
.status-badge.archived {
  background: #f2ebe7;
  color: var(--warm);
}

.location-status,
.form-error,
.admin-help {
  margin: -2px 0 0;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.35;
}

.form-error {
  min-height: 18px;
  color: var(--danger);
  font-weight: 760;
}

.toolbar {
  margin-bottom: 14px;
}

.toolbar input {
  flex: 1;
}

.toolbar select {
  max-width: 150px;
}

.entries {
  display: grid;
  gap: 12px;
}

.entry-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #ffffff;
  padding: 15px;
}

.entry-card__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.entry-meta,
.entry-notes,
.empty-state,
.ai-details,
.entry-details {
  color: var(--muted);
  line-height: 1.45;
}

.entry-meta {
  margin-bottom: 12px;
  font-size: 0.84rem;
}

.entry-notes {
  margin-bottom: 10px;
  color: var(--ink);
}

.entry-details,
.ai-details dl {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 6px 10px;
  margin: 0 0 10px;
  font-size: 0.84rem;
}

.entry-details dt,
.ai-details dt {
  color: var(--ink);
  font-weight: 850;
}

.entry-details dd,
.ai-details dd {
  margin: 0;
}

.media-preview {
  margin: 10px 0;
}

.media-attachment-grid {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.media-preview img {
  display: block;
  width: 100%;
  max-height: min(70vh, 720px);
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f8faf8;
}

.media-preview a {
  display: block;
  color: inherit;
  text-decoration: none;
}

.file-preview {
  border: 1px dashed var(--line);
  border-radius: 12px;
  padding: 12px;
  color: var(--muted);
  font-size: 0.88rem;
}

.ai-details {
  border-top: 1px solid var(--line);
  padding-top: 10px;
  font-size: 0.88rem;
}

.ai-details summary {
  margin-bottom: 8px;
  color: var(--accent-strong);
  cursor: pointer;
  font-weight: 850;
}

.card-actions,
.admin-actions {
  flex-wrap: wrap;
  padding-top: 4px;
}

.card-actions button {
  min-height: 38px;
  font-size: 0.82rem;
}

.empty-state,
.success-panel {
  margin: 0;
  border: 1px dashed var(--line);
  border-radius: 14px;
  padding: 20px;
  text-align: center;
}

.success-panel p {
  color: var(--muted);
}

.admin-drawer {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: stretch end;
  background: rgba(32, 33, 36, 0.38);
}

.admin-panel {
  width: min(540px, 100%);
  height: 100%;
  overflow: auto;
  border-radius: 16px 0 0 16px;
}

.admin-form textarea {
  min-height: 120px;
  font-family: inherit;
}

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

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

@media (max-width: 640px) {
  .app-header,
  .section-heading,
  .toolbar,
  .compact-grid,
  .admin-actions {
    align-items: stretch;
    flex-direction: column;
    grid-template-columns: 1fr;
  }

  .app-header {
    padding-top: 14px;
  }

  .header-actions {
    display: grid;
    grid-template-columns: 44px 1fr 1fr;
    width: 100%;
  }

  .app-shell {
    padding: 12px 9px 32px;
  }

  .quick-capture-grid {
    grid-template-columns: 1fr;
  }

  .capture-icon-card {
    min-height: 108px;
  }

  .toolbar select,
  .admin-actions > * {
    width: 100%;
    max-width: none;
  }

  .capture-panel,
  .review-panel,
  .admin-panel {
    border-radius: 14px;
  }

  .chip-grid {
    max-height: none;
    overflow: visible;
  }

  .admin-drawer {
    place-items: stretch;
  }

  .entry-card__header {
    flex-direction: column;
  }
}
