:root {
  color-scheme: light;
  --bg: #f6f7f8;
  --surface: #ffffff;
  --surface-soft: #eef3f1;
  --text: #1f2933;
  --muted: #68727d;
  --line: #d9dee4;
  --green: #2f7d64;
  --green-dark: #23634f;
  --blue: #376f9f;
  --coral: #b65d4a;
  --focus: #f0b84f;
  --shadow: 0 10px 28px rgba(31, 41, 51, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background:
    linear-gradient(180deg, #eef3f1 0, rgba(238, 243, 241, 0) 320px),
    var(--bg);
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(1160px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 40px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 8px 0 24px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--green);
  font-size: 0.78rem;
  font-weight: 700;
}

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

h1 {
  margin-bottom: 0;
  font-size: 2rem;
  line-height: 1.15;
}

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

.layout {
  display: grid;
  grid-template-columns: minmax(0, 0.88fr) minmax(360px, 1fr);
  gap: 20px;
  align-items: start;
}

.module-nav {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 18px;
}

.module-button {
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-weight: 700;
}

.module-button.active {
  border-color: var(--green);
  background: var(--green);
  color: #ffffff;
}

.entry-panel,
.records-panel,
.content-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 20px;
}

.records-panel {
  min-height: 520px;
}

.content-panel {
  min-height: 520px;
}

.section-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.save-hint,
.record-count {
  min-width: 54px;
  color: var(--muted);
  font-size: 0.88rem;
  text-align: right;
}

.record-type,
.filters,
.quick-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.record-type {
  margin-bottom: 18px;
}

.type-button,
.filter-button,
.quick-options button,
.secondary-action,
.primary-action,
.ghost-action,
.delete-button {
  min-height: 42px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  padding: 0 14px;
}

.type-button {
  flex: 1;
  min-width: 128px;
  font-weight: 700;
}

.type-button.active,
.filter-button.active,
.quick-options button.active {
  border-color: var(--green);
  background: var(--surface-soft);
  color: var(--green-dark);
}

.record-form {
  display: grid;
  gap: 16px;
}

.form-section {
  display: grid;
  gap: 16px;
}

.hidden {
  display: none;
}

.field {
  display: grid;
  gap: 8px;
}

.field span {
  color: var(--text);
  font-size: 0.95rem;
  font-weight: 700;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfc;
  color: var(--text);
  padding: 12px 13px;
  outline: none;
}

textarea {
  min-height: 96px;
  resize: vertical;
  line-height: 1.55;
}

input:focus,
textarea:focus,
button:focus-visible {
  border-color: var(--focus);
  box-shadow: 0 0 0 3px rgba(240, 184, 79, 0.24);
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding-top: 4px;
}

.primary-action {
  border-color: var(--green);
  background: var(--green);
  color: #ffffff;
  font-weight: 700;
}

.primary-action:hover {
  background: var(--green-dark);
}

.ghost-action {
  border-color: transparent;
  color: var(--muted);
}

.secondary-action:hover,
.filter-button:hover,
.type-button:hover,
.quick-options button:hover,
.ghost-action:hover {
  border-color: var(--green);
}

.template-box {
  display: grid;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfc;
  padding: 14px;
}

.template-heading span {
  display: block;
  margin-bottom: 5px;
  font-weight: 700;
}

.template-heading p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.5;
}

.template-section {
  display: grid;
  gap: 8px;
}

.template-section h3,
.learning-card h4,
.learning-card h5 {
  margin: 0;
  color: var(--text);
  line-height: 1.35;
}

.template-section h3 {
  font-size: 1rem;
}

.compact-field {
  gap: 6px;
}

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

.template-actions button {
  flex: 1;
  min-width: 118px;
}

.template-table,
.learning-table {
  width: 100%;
  border-collapse: collapse;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.template-table {
  table-layout: fixed;
}

.template-table th,
.template-table td,
.learning-table th,
.learning-table td {
  border-bottom: 1px solid var(--line);
  padding: 10px;
  vertical-align: top;
}

.template-table tr:last-child th,
.template-table tr:last-child td,
.learning-table tr:last-child th,
.learning-table tr:last-child td {
  border-bottom: 0;
}

.template-table th,
.learning-table th {
  color: var(--muted);
  background: var(--surface-soft);
  font-size: 0.9rem;
  text-align: left;
}

.two-col-table th:first-child,
.learning-table th:first-child {
  width: 92px;
}

.plan-table th:first-child {
  width: 84px;
}

.plan-table th:nth-child(2),
.plan-table th:nth-child(3) {
  width: calc((100% - 84px) / 2);
}

.template-table textarea {
  min-height: 58px;
  border: 0;
  border-radius: 0;
  background: transparent;
  padding: 0;
}

.template-table textarea:focus {
  box-shadow: none;
}

.learning-card {
  display: grid;
  gap: 12px;
  margin: 10px 0;
  overflow-x: auto;
}

.learning-card h4 {
  font-size: 1.12rem;
}

.learning-card h5 {
  margin-top: 6px;
  font-size: 0.98rem;
}

.learning-table td {
  white-space: pre-wrap;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.learning-content-view {
  display: grid;
  gap: 10px;
}

.day-picker {
  display: grid;
  gap: 10px;
  margin-bottom: 22px;
}

.day-select-field {
  display: grid;
  gap: 7px;
}

.day-select-field span {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

.day-select-field select {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfc;
  color: var(--text);
  padding: 0 12px;
  outline: none;
}

.day-select-field select:focus {
  border-color: var(--focus);
  box-shadow: 0 0 0 3px rgba(240, 184, 79, 0.24);
}

.day-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.day-tab {
  flex: 0 0 auto;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  padding: 0 12px;
  font-weight: 700;
}

.day-tab.active {
  border-color: var(--green);
  background: var(--surface-soft);
  color: var(--green-dark);
}

.learning-content-view h3 {
  margin-bottom: 0;
  font-size: 1.7rem;
  line-height: 1.25;
}

.swipe-hint {
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 0.92rem;
}

.learning-carousel {
  display: flex;
  gap: 14px;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
}

.learning-carousel::-webkit-scrollbar {
  display: none;
}

.learning-card-slide {
  flex: 0 0 100%;
  min-width: 100%;
  min-height: min(680px, calc(100svh - 260px));
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  scroll-snap-align: start;
  scroll-snap-stop: always;
  overflow: hidden;
}

.learning-card-scroll {
  display: grid;
  gap: 12px;
  height: 100%;
  max-height: min(680px, calc(100svh - 260px));
  overflow: auto;
  padding: 16px;
}

.learning-card-slide h4 {
  margin: 0;
  font-size: 1.15rem;
}

.carousel-dots {
  display: flex;
  justify-content: center;
  gap: 7px;
  padding-top: 4px;
}

.carousel-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--line);
}

.carousel-dot.active {
  background: var(--green);
}

.filters {
  margin-bottom: 14px;
}

.records-list {
  display: grid;
  gap: 12px;
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 320px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
  padding: 24px;
}

.record-item {
  position: relative;
  border: 1px solid var(--line);
  border-left: 5px solid var(--green);
  border-radius: 8px;
  background: #ffffff;
  padding: 14px;
}

.record-item.learning {
  border-left-color: var(--blue);
}

.record-item.behavior {
  border-left-color: var(--coral);
}

.record-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 9px;
  color: var(--muted);
  font-size: 0.85rem;
}

.record-badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--green-dark);
  padding: 0 10px;
  font-weight: 700;
}

.record-item.learning .record-badge {
  background: #e8f1f8;
  color: var(--blue);
}

.record-item.behavior .record-badge {
  background: #f7ece8;
  color: var(--coral);
}

.record-item h3 {
  margin-bottom: 8px;
  padding-right: 56px;
  font-size: 1rem;
  line-height: 1.45;
}

.record-summary {
  margin-bottom: 10px;
  color: var(--muted);
  line-height: 1.55;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.record-detail {
  display: grid;
  gap: 8px;
  margin: 0;
}

.record-detail div {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  gap: 8px;
}

.record-detail dt {
  color: var(--muted);
  font-weight: 700;
}

.record-detail dd {
  margin: 0;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.delete-button {
  position: absolute;
  top: 12px;
  right: 12px;
  min-height: 32px;
  padding: 0 9px;
  color: var(--muted);
  font-size: 0.85rem;
}

.delete-button:hover {
  border-color: var(--coral);
  color: var(--coral);
}

@media (max-width: 860px) {
  .app-shell {
    width: min(100% - 20px, 680px);
    padding-top: 14px;
  }

  .topbar {
    align-items: flex-start;
  }

  h1 {
    font-size: 1.62rem;
  }

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

  .module-nav {
    grid-template-columns: 1fr;
  }

  .entry-panel,
  .records-panel {
    padding: 16px;
  }
}

@media (max-width: 520px) {
  .topbar {
    flex-direction: column;
  }

  .topbar .primary-action,
  .form-actions button {
    width: 100%;
  }

  .form-actions {
    flex-direction: column-reverse;
  }

  .record-detail div {
    grid-template-columns: 1fr;
    gap: 2px;
  }

  .two-col-table th:first-child,
  .learning-table th:first-child,
  .plan-table th:first-child {
    width: 76px;
  }

  .plan-table {
    min-width: 640px;
  }
}
