:root {
  color-scheme: light;
  --bg: #f7f4ef;
  --surface: #fffdf8;
  --surface-strong: #ffffff;
  --ink: #202124;
  --muted: #63615c;
  --line: #ded8ce;
  --primary: #245b63;
  --primary-strong: #173f45;
  --accent: #d86f45;
  --accent-soft: #f7dfd4;
  --green-soft: #ecf4f2;
  --code-bg: #18262b;
  --shadow: 0 18px 48px rgba(50, 45, 38, 0.12);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--bg);
}

body {
  margin: 0;
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  line-height: 1.7;
  letter-spacing: 0;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

a {
  color: inherit;
  text-decoration: none;
}

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

h1 {
  max-width: 900px;
  margin-bottom: 12px;
  font-size: clamp(2.3rem, 5vw, 4.8rem);
  line-height: 1.05;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 8px;
  font-size: clamp(1.5rem, 2.4vw, 2.2rem);
  line-height: 1.18;
  letter-spacing: 0;
}

h3 {
  margin-bottom: 8px;
  font-size: 1rem;
  letter-spacing: 0;
}

code {
  border-radius: 5px;
  background: rgba(36, 91, 99, 0.1);
  color: var(--primary-strong);
  padding: 0.05rem 0.32rem;
}

.app-header {
  display: grid;
  gap: 28px;
  padding: 56px clamp(20px, 7vw, 96px) 34px;
  border-bottom: 1px solid var(--line);
  background:
    linear-gradient(135deg, rgba(36, 91, 99, 0.08), transparent 42%),
    linear-gradient(90deg, rgba(216, 111, 69, 0.12), transparent 55%),
    var(--surface);
}

.top-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.top-nav a {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.7);
  color: var(--muted);
  padding: 7px 14px;
  font-weight: 800;
}

.top-nav a.is-active,
.top-nav a:hover {
  border-color: var(--primary);
  background: var(--primary);
  color: #ffffff;
}

.eyebrow,
.section-label {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.lead {
  max-width: 760px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 1.05rem;
}

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

.toolbar {
  display: grid;
  gap: 14px;
  margin-bottom: 22px;
}

.search-box {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.search-box input {
  width: 100%;
  min-height: 52px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  color: var(--ink);
  padding: 0 16px;
  outline: none;
}

.search-box input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(36, 91, 99, 0.16);
}

.category-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.category-chip {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-strong);
  color: var(--muted);
  padding: 0 13px;
}

.category-chip.is-active {
  border-color: var(--primary);
  background: var(--primary);
  color: #ffffff;
}

.dictionary-grid {
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  gap: 22px;
  align-items: start;
}

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

.section-heading .section-label {
  margin-bottom: 0;
}

.section-heading span {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

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

.entry-list-body {
  display: grid;
  gap: 10px;
}

.entry-card,
.date-entry-card {
  display: grid;
  width: 100%;
  min-height: 130px;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  color: inherit;
  padding: 16px;
  text-align: left;
}

.entry-card:hover,
.entry-card.is-selected,
.date-entry-card:hover {
  border-color: var(--primary);
  box-shadow: 0 12px 26px rgba(36, 91, 99, 0.12);
}

.entry-card.is-selected {
  background: var(--green-soft);
}

.entry-card-top {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.entry-card-top strong {
  line-height: 1.35;
}

.entry-card-top small,
.date-entry-card small {
  border-radius: 999px;
  background: var(--accent-soft);
  color: #8a3d21;
  padding: 2px 9px;
  font-size: 0.76rem;
  font-weight: 800;
  white-space: nowrap;
}

.entry-date,
.entry-summary,
.detail-section p,
.answer-box p {
  color: var(--muted);
}

.entry-summary {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.entry-detail {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  box-shadow: var(--shadow);
}

.detail-header,
.answer-box,
.detail-section,
.empty-state {
  padding: 22px clamp(18px, 3vw, 30px);
  border-bottom: 1px solid var(--line);
}

.detail-header h2 {
  margin-bottom: 2px;
}

.answer-box {
  background: var(--green-soft);
}

.detail-section:last-child,
.empty-state:last-child {
  border-bottom: 0;
}

.detail-section p,
.answer-box p {
  margin-bottom: 0;
}

.diagram {
  width: 100%;
  min-width: 0;
  border-radius: 8px;
  background: #ffffff;
}

pre {
  overflow-x: auto;
  margin: 0;
  border-radius: 8px;
  background: var(--code-bg);
  color: #e8f3f0;
  padding: 16px;
}

pre code {
  background: transparent;
  color: inherit;
  padding: 0;
}

.log-toolbar {
  grid-template-columns: minmax(0, 1fr) 220px;
  align-items: end;
}

.log-summary {
  display: grid;
  min-height: 52px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  padding: 8px 14px;
}

.log-summary strong {
  color: var(--primary-strong);
  font-size: 1.25rem;
  line-height: 1.25;
}

.log-summary span {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

.date-groups {
  display: grid;
  gap: 18px;
}

.date-group {
  display: grid;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 18px;
}

.date-group-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 10px;
}

.date-group-header h2 {
  margin-bottom: 0;
  color: var(--primary-strong);
}

.date-group-header span {
  color: var(--muted);
  font-weight: 700;
}

.date-entry-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.date-entry-card {
  min-height: 116px;
}

@media (max-width: 900px) {
  .dictionary-grid,
  .log-toolbar,
  .date-entry-list {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .app-header {
    padding-top: 34px;
  }

  .layout {
    width: min(100% - 22px, 1180px);
    padding-top: 18px;
  }

  .entry-card {
    min-height: auto;
  }

  .detail-header,
  .answer-box,
  .detail-section,
  .empty-state,
  .date-group {
    padding: 16px;
  }

  .date-group-header {
    display: grid;
    gap: 2px;
  }
}
