:root {
  color-scheme: light;
  --bg: oklch(0.988 0.001 260);
  --surface: oklch(1 0 0);
  --surface-warm: oklch(0.965 0.004 260);
  --ink: oklch(0.17 0.012 260);
  --muted: oklch(0.43 0.018 260);
  --line: oklch(0.875 0.008 260);
  --accent: oklch(0.6 0.16 34);
  --accent-deep: oklch(0.42 0.13 32);
  --accent-soft: oklch(0.93 0.032 36);
  --sage: oklch(0.58 0.085 142);
  --blue: oklch(0.55 0.105 238);
  --red: oklch(0.54 0.13 25);
  --shadow-soft: 0 18px 52px oklch(0.2 0.012 260 / 0.12);
  --shadow-tight: 0 8px 24px oklch(0.2 0.012 260 / 0.08);
  --radius: 14px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

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

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

button {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid oklch(0.68 0.14 34 / 0.45);
  outline-offset: 2px;
}

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

.topbar {
  position: sticky;
  top: 16px;
  z-index: 10;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  margin-bottom: 14px;
}

.search-wrap {
  position: relative;
  display: block;
}

.search-wrap input {
  width: 100%;
  height: 58px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: oklch(1 0 0 / 0.88);
  box-shadow: var(--shadow-tight);
  color: var(--ink);
  padding: 0 22px 0 56px;
  backdrop-filter: blur(18px);
}

.search-wrap input::placeholder {
  color: var(--muted);
  opacity: 1;
}

.search-icon {
  position: absolute;
  left: 22px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--accent-deep);
  font-size: 1.35rem;
}

.top-actions {
  display: flex;
  gap: 10px;
}

.icon-button,
.capture-button,
.tab,
.primary-button {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  min-height: 44px;
  padding: 0 16px;
  box-shadow: var(--shadow-tight);
}

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

.capture-button,
.primary-button,
.tab.active {
  border-color: transparent;
  background: var(--accent);
  color: white;
}

.capture-button:hover,
.primary-button:hover,
.tab.active:hover {
  background: var(--accent-deep);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent-deep);
  font-size: 0.77rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 0;
  font-size: 1.65rem;
  line-height: 1.12;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0;
  font-size: 1.55rem;
  line-height: 1.12;
}

h3 {
  margin-bottom: 10px;
  font-size: 1.05rem;
}

p {
  color: var(--muted);
  line-height: 1.62;
}

.workspace-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  margin-bottom: 0;
}

.tab {
  box-shadow: none;
  min-height: 38px;
}

.sync-status {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
  white-space: nowrap;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

.view-title {
  margin: 0 0 14px;
  color: var(--ink);
  font-size: 1.35rem;
}

.view-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.section-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 16px;
}

.section-head > p {
  margin-bottom: 0;
  text-align: right;
}

.clip-grid {
  column-count: 3;
  column-gap: 16px;
}

.clip-card {
  display: inline-block;
  width: 100%;
  margin: 0 0 16px;
  break-inside: avoid;
}

.clip-open {
  display: block;
  width: 100%;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: inherit;
  padding: 0;
  text-align: left;
}

.clip-inner {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-tight);
  transition:
    transform 180ms ease,
    box-shadow 180ms ease,
    border-color 180ms ease;
}

.clip-open:hover .clip-inner {
  transform: translateY(-3px);
  border-color: oklch(0.72 0.07 34);
  box-shadow: var(--shadow-soft);
}

.clip-media {
  display: grid;
  min-height: 180px;
  place-items: center;
  border-bottom: 1px solid var(--line);
  background:
    linear-gradient(180deg, var(--accent) 0 4px, transparent 4px),
    linear-gradient(135deg, oklch(0.985 0.002 260), oklch(0.948 0.006 260));
  color: var(--accent-deep);
  font-size: 3rem;
  font-weight: 800;
}

.clip-media img {
  display: block;
  width: 100%;
  height: auto;
}

.clip-body {
  padding: 18px;
}

.clip-type {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 999px;
  background: oklch(0.955 0.018 34);
  color: var(--accent-deep);
  padding: 0 9px;
  font-size: 0.75rem;
  font-weight: 800;
}

.clip-title {
  margin: 12px 0 8px;
  color: var(--ink);
  font-size: 1.18rem;
  line-height: 1.22;
  text-wrap: pretty;
}

.quote {
  margin: 0;
  color: var(--ink);
  font-size: 1.05rem;
  line-height: 1.55;
}

.quote::before {
  content: "“";
  color: var(--accent);
}

.quote::after {
  content: "”";
  color: var(--accent);
}

.context-line {
  margin: 10px 0 0;
  font-size: 0.93rem;
}

.word-row,
.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.word-row {
  margin-top: 14px;
}

.tag-row {
  margin-top: 12px;
}

.word-chip,
.tag-chip {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  min-height: 28px;
  border-radius: 999px;
  padding: 0 10px;
  font-size: 0.82rem;
  font-weight: 750;
}

.word-chip {
  background: var(--accent);
  color: white;
}

.tag-chip {
  background: oklch(0.94 0.006 260);
  color: var(--muted);
}

.capture-layout,
.rediscover-wrap {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.capture-panel,
.rediscover-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-tight);
}

.capture-panel {
  display: grid;
  gap: 16px;
  padding: 22px;
}

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

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 760;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  padding: 11px 12px;
}

textarea {
  min-height: 112px;
  resize: vertical;
}

.form-actions {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.form-actions p {
  max-width: 52ch;
  margin-bottom: 0;
  font-size: 0.92rem;
}

.word-cloud {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
}

.word-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-tight);
  padding: 18px;
}

.word-card button {
  border: 0;
  background: transparent;
  color: inherit;
  padding: 0;
  text-align: left;
}

.word-card h3 {
  margin-bottom: 4px;
  font-size: 1.45rem;
  overflow-wrap: anywhere;
}

.word-meta {
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 0.88rem;
}

.word-card p {
  margin-bottom: 0;
}

.rediscover-card {
  overflow: hidden;
}

.rediscover-card .clip-card {
  margin: 0;
}

.empty-state {
  display: grid;
  min-height: 220px;
  place-items: center;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  color: var(--muted);
  background: oklch(1 0 0 / 0.72);
}

.clip-dialog {
  width: min(860px, calc(100% - 28px));
  max-height: calc(100vh - 38px);
  border: 0;
  border-radius: 20px;
  background: var(--surface);
  box-shadow: 0 26px 90px oklch(0.12 0.02 60 / 0.28);
  padding: 0;
}

.clip-dialog::backdrop {
  background: oklch(0.16 0.018 70 / 0.42);
  backdrop-filter: blur(6px);
}

.dialog-close {
  position: absolute;
  right: 14px;
  top: 14px;
  z-index: 2;
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 50%;
  background: oklch(1 0 0 / 0.84);
  color: var(--ink);
  font-size: 1.5rem;
  line-height: 1;
}

.detail {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  min-height: 520px;
}

.detail-main {
  padding: 30px;
}

.detail-main h2 {
  margin: 10px 0 16px;
  font-size: 2rem;
  line-height: 1.08;
}

.detail-side {
  border-left: 1px solid var(--line);
  background: var(--surface-warm);
  padding: 30px 22px;
}

.detail-media {
  overflow: hidden;
  border-radius: 14px;
  background:
    linear-gradient(180deg, var(--accent) 0 4px, transparent 4px),
    linear-gradient(135deg, oklch(0.985 0.002 260), oklch(0.948 0.006 260));
  margin-bottom: 18px;
}

.detail-media img {
  display: block;
  width: 100%;
}

.detail-placeholder {
  display: grid;
  min-height: 220px;
  place-items: center;
  color: var(--accent-deep);
  font-size: 4rem;
  font-weight: 850;
}

.source-link {
  color: var(--accent-deep);
  font-weight: 800;
  overflow-wrap: anywhere;
}

.source-link:hover {
  color: var(--accent);
}

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

@media (max-width: 980px) {
  .capture-layout,
  .rediscover-wrap,
  .detail {
    grid-template-columns: 1fr;
  }

  .clip-grid {
    column-count: 2;
  }

  .detail-side {
    border-left: 0;
    border-top: 1px solid var(--line);
  }
}

@media (max-width: 660px) {
  .app-shell {
    width: min(100% - 20px, 1180px);
    padding-top: 10px;
  }

  .topbar {
    grid-template-columns: 1fr;
    top: 10px;
  }

  .top-actions {
    justify-content: space-between;
  }

  .workspace-bar {
    align-items: flex-start;
    flex-direction: column;
  }

  .sync-status {
    white-space: normal;
  }

  .clip-grid {
    column-count: 1;
  }

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

  .detail-main,
  .detail-side {
    padding: 22px;
  }
}
