:root {
  color-scheme: light;
  --bg: #f7f4ee;
  --panel: #fffdf8;
  --ink: #202124;
  --muted: #6b6f76;
  --line: #d8d1c4;
  --green: #287a5b;
  --green-soft: #e5f1ea;
  --blue: #2d6cdf;
  --blue-soft: #e7eefc;
  --amber: #a46008;
  --amber-soft: #f7ead7;
  --red: #b2382f;
  --red-soft: #f7e3e0;
  --shadow: 0 10px 28px rgba(52, 48, 42, 0.1);
}

* {
  box-sizing: border-box;
}

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

[hidden] {
  display: none !important;
}

button,
input,
textarea {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

.icon-sprite {
  display: none;
}

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

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: max(14px, env(safe-area-inset-top)) 18px 14px;
  background: rgba(247, 244, 238, 0.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
}

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

h1 {
  font-size: 24px;
  font-weight: 780;
  letter-spacing: 0;
}

h2 {
  font-size: 16px;
  font-weight: 720;
  letter-spacing: 0;
}

h3 {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0;
}

.health,
.muted {
  color: var(--muted);
  font-size: 13px;
}

.health.ok {
  color: var(--green);
}

.health.bad {
  color: var(--red);
}

.login-view {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 18px;
}

.login-panel {
  display: grid;
  width: min(420px, 100%);
  gap: 14px;
  padding: 22px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.login-subtitle {
  margin-top: 4px;
  color: var(--muted);
  font-size: 14px;
}

.field {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 680;
}

.field input {
  color: var(--ink);
  font-size: 16px;
  font-weight: 500;
}

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

.user-badge,
.user-line {
  color: var(--muted);
  font-size: 13px;
}

.user-badge {
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 720;
}

.user-line {
  flex: 1 1 auto;
}

.icon-button {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
}

.icon-button:active,
.capture-button:active,
.send-button:active {
  transform: translateY(1px);
}

.app-shell {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 16px;
}

.capture {
  display: grid;
  gap: 12px;
  padding-bottom: 16px;
}

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

.capture-button {
  display: grid;
  min-height: 76px;
  align-content: center;
  justify-items: center;
  gap: 6px;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
}

.capture-button.camera {
  border-color: #c3d4f4;
  background: var(--blue-soft);
}

.capture-button.mic {
  border-color: #ddc39e;
  background: var(--amber-soft);
}

.capture-button.paste {
  border-color: #c8d6df;
  background: #eef3f7;
}

.capture-button.scan {
  border-color: #d4c6ef;
  background: #f0ecf8;
}

.capture-button.text {
  border-color: #b9d7ca;
  background: var(--green-soft);
}

.capture-button.upload {
  background: #fdfdfd;
}

.capture-button.recording {
  color: #fff;
  background: var(--red);
  border-color: var(--red);
}

.capture-button.active {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(40, 122, 91, 0.13);
}

.capture-button span {
  display: block;
  max-width: 100%;
  overflow-wrap: anywhere;
  font-size: 13px;
  font-weight: 700;
}

.text-form {
  display: grid;
  gap: 10px;
}

.scan-panel {
  display: grid;
  gap: 10px;
  padding: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.scan-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.scan-actions {
  display: flex;
  gap: 8px;
}

.scan-thumbs {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
  gap: 8px;
}

.scan-thumb {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 3 / 4;
  overflow: hidden;
  padding: 0;
  background: #f8f8f5;
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
}

.scan-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.scan-thumb span {
  position: absolute;
  top: 5px;
  left: 5px;
  display: grid;
  min-width: 22px;
  height: 22px;
  place-items: center;
  color: #fff;
  background: rgba(32, 33, 36, 0.72);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 760;
}

.meta-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

input,
textarea {
  width: 100%;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: none;
}

input {
  height: 42px;
  padding: 0 12px;
}

textarea {
  min-height: 124px;
  resize: vertical;
  padding: 12px;
}

input:focus,
textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(45, 108, 223, 0.16);
}

.record-time {
  min-width: 64px;
  color: var(--red);
  font-variant-numeric: tabular-nums;
  font-weight: 760;
}

.send-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 46px;
  color: #fff;
  background: var(--green);
  border: 1px solid var(--green);
  border-radius: 8px;
  cursor: pointer;
  font-weight: 760;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(320px, 0.9fr) minmax(420px, 1.25fr);
  gap: 14px;
  min-width: 0;
}

.list-pane,
.detail-pane {
  min-width: 0;
  max-width: 100%;
}

.pane-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 38px;
}

.items {
  display: grid;
  gap: 8px;
  min-width: 0;
  max-width: 100%;
}

.item-row {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  display: grid;
  gap: 6px;
  padding: 12px;
  overflow: hidden;
  text-align: left;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: none;
  cursor: pointer;
}

.item-row.active {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(40, 122, 91, 0.13);
}

.item-row-main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  min-width: 0;
  max-width: 100%;
}

.item-title {
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  display: -webkit-box;
  overflow-wrap: anywhere;
  white-space: normal;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  font-weight: 720;
}

.detail-title {
  min-width: 0;
  max-width: 100%;
  overflow-wrap: anywhere;
  white-space: normal;
  font-weight: 720;
}

.item-subtitle {
  display: -webkit-box;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  overflow-wrap: anywhere;
  color: var(--muted);
  font-size: 13px;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.status {
  flex: 0 0 auto;
  padding: 3px 7px;
  color: var(--muted);
  background: #f0eee9;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 720;
}

.status.processed {
  color: var(--green);
  background: var(--green-soft);
}

.status.processing,
.status.queued {
  color: var(--amber);
  background: var(--amber-soft);
}

.status.error {
  color: var(--red);
  background: var(--red-soft);
}

.detail-pane {
  min-height: 360px;
  padding: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.detail-empty {
  display: grid;
  min-height: 260px;
  place-items: center;
  color: var(--muted);
}

.detail-head {
  display: grid;
  gap: 6px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.detail-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.artifact-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 8px;
  margin: 14px 0;
}

.artifact-link {
  display: flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  padding: 8px;
  color: var(--ink);
  text-decoration: none;
  background: #f8f8f5;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 13px;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.artifact-content {
  display: grid;
  gap: 12px;
}

.text-block {
  max-height: 460px;
  overflow: auto;
  margin: 0;
  padding: 12px;
  color: var(--ink);
  background: #f8f8f5;
  border: 1px solid var(--line);
  border-radius: 8px;
  white-space: pre-wrap;
  word-break: break-word;
  font: 13px/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.detail-image,
.detail-audio {
  width: 100%;
  max-width: 100%;
  border-radius: 8px;
  border: 1px solid var(--line);
}

.toast {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 20;
  max-width: min(360px, calc(100vw - 32px));
  padding: 12px 14px;
  color: #fff;
  background: #202124;
  border-radius: 8px;
  box-shadow: var(--shadow);
  font-size: 14px;
}

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

  .capture-actions {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 7px;
  }

  .capture-button {
    min-height: 68px;
  }

  .capture-button span {
    font-size: 12px;
  }

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

  .detail-pane {
    min-height: 280px;
  }
}

@media (max-width: 420px) {
  .topbar {
    padding-left: 12px;
    padding-right: 12px;
  }

  .top-actions {
    gap: 6px;
  }

  .user-badge {
    max-width: 96px;
  }

  h1 {
    font-size: 21px;
  }

  .capture-button {
    min-height: 62px;
  }

  .capture-button svg {
    width: 18px;
    height: 18px;
  }
}
