:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #eef3f5;
  --ink: #151820;
  --muted: #68717d;
  --line: #dce2e7;
  --accent: #f5c542;
  --accent-ink: #251d00;
  --teal: #147d73;
  --blue: #2e6dd8;
  --coral: #db5b57;
  --violet: #7157c8;
  --green: #277f4f;
  --shadow: 0 16px 40px rgba(26, 32, 44, .08);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  color-scheme: light;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(245, 197, 66, .2), rgba(246, 247, 249, 0) 220px),
    var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Malgun Gothic", sans-serif;
  letter-spacing: 0;
}

button,
input,
select,
textarea {
  font: inherit;
  letter-spacing: 0;
}

button {
  cursor: pointer;
}

.icon-sprite {
  display: none;
}

.app-shell {
  width: min(1440px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 18px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 56px;
  margin-bottom: 14px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
  min-width: 0;
}

.brand-mark,
.empty-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 900;
  box-shadow: 0 10px 24px rgba(245, 197, 66, .28);
}

.brand strong {
  display: block;
  font-size: 18px;
  line-height: 1.1;
}

.brand small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.top-actions,
.capture-actions,
.item-actions,
.detail-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(280px, 330px) minmax(0, 1fr) minmax(300px, 360px);
  gap: 14px;
  align-items: start;
}

.sidebar,
.list-pane,
.detail-pane {
  min-width: 0;
}

.capture-panel,
.filter-panel,
.stats-panel,
.list-pane,
.detail-pane {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, .88);
  box-shadow: var(--shadow);
}

.capture-panel,
.filter-panel,
.stats-panel {
  padding: 14px;
}

.sidebar {
  display: grid;
  gap: 12px;
  position: sticky;
  top: 18px;
}

.panel-head,
.list-toolbar,
.detail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

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

h1 {
  font-size: 18px;
}

h2 {
  font-size: 22px;
}

h3 {
  font-size: 15px;
  line-height: 1.35;
}

.eyebrow {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

textarea {
  width: 100%;
  min-height: 156px;
  margin: 12px 0;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
  color: var(--ink);
  padding: 12px;
  outline: none;
  line-height: 1.5;
}

textarea:focus,
input:focus,
select:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(20, 125, 115, .12);
}

.icon-button,
.primary-button,
.ghost-button,
.seg,
.chip,
.mini-button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  padding: 0;
}

.icon-button.compact {
  width: 36px;
  height: 36px;
  flex-basis: 36px;
}

svg {
  width: 19px;
  height: 19px;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
}

.primary-button,
.ghost-button,
.mini-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 14px;
  font-weight: 800;
  white-space: nowrap;
}

.primary-button {
  flex: 1;
  border-color: #e2af16;
  background: var(--accent);
  color: var(--accent-ink);
}

.ghost-button {
  flex: 0 0 auto;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
}

.search-box svg {
  color: var(--muted);
  flex: 0 0 auto;
}

.search-box input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
}

.filter-group {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  margin-top: 10px;
}

.seg {
  min-height: 36px;
  padding: 0 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.seg.active {
  border-color: rgba(20, 125, 115, .45);
  background: rgba(20, 125, 115, .1);
  color: var(--teal);
}

.chip-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
  margin-top: 12px;
}

.chip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 38px;
  padding: 0 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.chip.active {
  border-color: currentColor;
  background: color-mix(in srgb, currentColor 10%, white);
  color: var(--chip-color, var(--teal));
}

.chip .dot {
  width: 9px;
  height: 9px;
  flex: 0 0 9px;
  border-radius: 50%;
  background: currentColor;
}

.stats-panel {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.stats-panel div {
  min-width: 0;
}

.stats-panel strong {
  display: block;
  font-size: 20px;
}

.stats-panel span {
  display: block;
  color: var(--muted);
  font-size: 11px;
}

.list-pane {
  min-height: calc(100vh - 88px);
  padding: 16px;
}

.list-toolbar {
  margin-bottom: 12px;
}

.sort-control {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 40px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
}

.sort-control select {
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font-weight: 800;
}

.list {
  display: grid;
  gap: 10px;
}

.item-card {
  display: grid;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 12px;
  transition: border-color .15s ease, transform .15s ease, box-shadow .15s ease;
}

.item-card:hover,
.item-card.is-selected {
  border-color: rgba(20, 125, 115, .55);
  box-shadow: 0 12px 28px rgba(20, 125, 115, .1);
}

.item-card.is-selected {
  transform: translateY(-1px);
}

.item-main {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  text-align: left;
  border: 0;
  background: transparent;
  color: inherit;
  padding: 0;
}

.category-icon {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: color-mix(in srgb, var(--cat-color) 12%, white);
  color: var(--cat-color);
  font-weight: 900;
}

.item-title-row {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 10px;
}

.item-title-row time {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 12px;
}

.excerpt,
.detail-text {
  overflow-wrap: anywhere;
  word-break: keep-all;
}

.excerpt {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.meta-row,
.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  max-width: 100%;
  border-radius: 8px;
  padding: 0 8px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.pill.category {
  background: color-mix(in srgb, var(--cat-color) 12%, white);
  color: var(--cat-color);
}

.item-actions {
  justify-content: flex-end;
}

.mini-button {
  min-width: 36px;
  min-height: 34px;
  padding: 0 9px;
  color: var(--muted);
  font-size: 12px;
}

.mini-button.is-on {
  border-color: currentColor;
  color: var(--teal);
  background: rgba(20, 125, 115, .08);
}

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

.detail-pane {
  position: sticky;
  top: 18px;
  min-height: calc(100vh - 88px);
  padding: 16px;
}

.detail-empty {
  min-height: calc(100vh - 122px);
  display: grid;
  place-items: center;
  align-content: center;
  gap: 12px;
  color: var(--muted);
  text-align: center;
}

.detail-head {
  margin-bottom: 12px;
}

.detail-title {
  min-width: 0;
}

.detail-title h2 {
  overflow-wrap: anywhere;
  word-break: keep-all;
}

.detail-body {
  display: grid;
  gap: 14px;
}

.detail-text {
  white-space: pre-wrap;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
  padding: 12px;
  line-height: 1.55;
}

.detail-links {
  display: grid;
  gap: 8px;
}

.link-button {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--blue);
  padding: 0 10px;
  text-decoration: none;
  font-weight: 800;
}

.link-button span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.property-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.property {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px;
}

.property span {
  display: block;
  color: var(--muted);
  font-size: 11px;
}

.property strong {
  display: block;
  margin-top: 3px;
  overflow-wrap: anywhere;
  font-size: 13px;
}

.empty-state {
  min-height: 360px;
  display: grid;
  place-items: center;
  color: var(--muted);
  text-align: center;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, .55);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 18px;
  z-index: 20;
  max-width: min(420px, calc(100vw - 32px));
  min-height: 42px;
  transform: translate(-50%, 20px);
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #151820;
  color: #fff;
  padding: 9px 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .16s ease, transform .16s ease;
  box-shadow: 0 16px 40px rgba(0, 0, 0, .2);
  text-align: center;
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

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

@media (max-width: 1120px) {
  .workspace {
    grid-template-columns: minmax(260px, 320px) minmax(0, 1fr);
  }

  .detail-pane {
    position: fixed;
    inset: 0 0 0 auto;
    z-index: 15;
    width: min(420px, 100vw);
    min-height: 100vh;
    border-radius: 0;
    transform: translateX(100%);
    transition: transform .18s ease;
    overflow: auto;
  }

  .detail-pane.is-open {
    transform: translateX(0);
  }
}

@media (max-width: 760px) {
  .app-shell {
    padding: 12px;
  }

  .topbar {
    margin-bottom: 10px;
  }

  .brand strong {
    font-size: 16px;
  }

  .workspace {
    grid-template-columns: minmax(0, 1fr);
  }

  .sidebar {
    position: static;
  }

  .capture-panel,
  .filter-panel,
  .stats-panel,
  .list-pane {
    box-shadow: none;
  }

  .chip-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .list-pane {
    min-height: auto;
    padding: 12px;
  }

  .list-toolbar {
    align-items: flex-start;
  }

  h2 {
    font-size: 19px;
  }

  .sort-control {
    width: 128px;
  }

  .item-title-row {
    display: grid;
    gap: 4px;
  }

  .item-title-row time {
    justify-self: start;
  }

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

@media (max-width: 430px) {
  .top-actions {
    gap: 6px;
  }

  .icon-button {
    width: 38px;
    height: 38px;
    flex-basis: 38px;
  }

  .capture-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr) repeat(2, 76px);
  }

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

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