:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-muted: #f9fafb;
  --ink: #171a1f;
  --muted: #717784;
  --soft: #a3aab6;
  --line: #e4e7ec;
  --line-strong: #d3d8e0;
  --accent: #116a67;
  --accent-strong: #0d5552;
  --accent-soft: #e7f4f2;
  --danger: #c0392b;
  --danger-soft: #fff1ef;
  --focus: #3b82f6;
  --shadow: 0 16px 40px rgba(23, 26, 31, 0.07);
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100%;
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(180deg, #ffffff 0, #f7f8fa 240px, var(--bg) 520px),
    var(--bg);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang SC", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: geometricPrecision;
}

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

button,
select {
  touch-action: manipulation;
}

button {
  appearance: none;
}

.app-shell {
  width: min(1320px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 28px 24px 36px;
}

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  padding: 4px 0 24px;
}

.topbar h1,
.topbar p,
.panel-heading h2,
.content-heading h2,
.content-heading p {
  margin: 0;
}

.topbar h1 {
  font-size: 28px;
  font-weight: 760;
  line-height: 1.05;
  letter-spacing: 0;
}

.topbar p {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-top: 9px;
  color: var(--muted);
  font-size: 13px;
}

.topbar p::before {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: var(--accent);
  content: "";
}

.module-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(82px, 1fr));
  gap: 3px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #eef1f5;
}

.tab-button,
.quiet-button,
.danger-button,
.primary-button,
.icon-button {
  min-height: 36px;
  border: 1px solid transparent;
  border-radius: 7px;
  cursor: pointer;
  transition:
    background 0.16s ease,
    border-color 0.16s ease,
    color 0.16s ease,
    box-shadow 0.16s ease,
    transform 0.16s ease;
}

.tab-button {
  padding: 0 16px;
  color: #636b78;
  background: transparent;
  font-size: 14px;
  font-weight: 720;
}

.tab-button.active {
  color: var(--ink);
  background: #ffffff;
  box-shadow: 0 1px 3px rgba(23, 26, 31, 0.08);
}

.workspace {
  display: grid;
  grid-template-columns: 252px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.groups-panel,
.content-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.groups-panel {
  position: sticky;
  top: 18px;
  padding: 14px;
}

.panel-heading,
.content-heading,
.composer-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.panel-heading h2,
.content-heading h2 {
  color: #2c3138;
  font-size: 15px;
  font-weight: 760;
  line-height: 1.25;
  letter-spacing: 0;
}

.group-list {
  display: grid;
  gap: 6px;
  margin-top: 12px;
}

.group-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 30px;
  gap: 4px;
  align-items: stretch;
  padding-left: calc(var(--depth, 0) * 14px);
}

.group-button {
  width: 100%;
  min-height: 42px;
  padding: 8px 10px;
  border: 1px solid transparent;
  border-radius: 7px;
  color: var(--ink);
  background: transparent;
  text-align: left;
  cursor: pointer;
  transition:
    background 0.16s ease,
    border-color 0.16s ease,
    color 0.16s ease;
}

.group-child-button {
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 7px;
  color: var(--soft);
  background: transparent;
  cursor: pointer;
  font-size: 15px;
  font-weight: 760;
}

.group-child-button:hover {
  color: var(--ink);
  background: var(--surface-muted);
}

.group-button:hover {
  background: var(--surface-muted);
}

.group-button.active {
  border-color: #b9d9d5;
  background: var(--accent-soft);
}

.group-name {
  display: block;
  overflow: hidden;
  font-size: 14px;
  font-weight: 720;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.group-count {
  display: block;
  margin-top: 1px;
  color: var(--muted);
  font-size: 12px;
}

.content-panel {
  min-width: 0;
  padding: 18px;
}

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

.content-heading {
  align-items: flex-start;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.content-heading h2 {
  font-size: 20px;
}

.title-edit-shell {
  width: min(520px, 100%);
}

.title-edit-button {
  max-width: min(520px, 100%);
  min-height: 0;
  border: 0;
  border-radius: 6px;
  padding: 2px 4px;
  color: inherit;
  background: transparent;
  cursor: pointer;
  font: inherit;
  font-weight: inherit;
  overflow-wrap: anywhere;
  text-align: left;
}

.title-edit-button:hover {
  background: var(--surface-muted);
}

.title-edit-input {
  width: min(520px, 100%);
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 2px 8px;
  color: var(--ink);
  background: #ffffff;
  font: inherit;
  font-weight: inherit;
  outline: none;
}

.title-edit-input:focus {
  border-color: var(--focus);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.16);
}

.content-heading p {
  margin-top: 5px;
  color: var(--muted);
  font-size: 13px;
}

.group-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.composer {
  display: grid;
  gap: 10px;
  padding: 16px 0;
}

textarea {
  width: 100%;
  min-height: 92px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 13px 14px;
  color: var(--ink);
  background: #ffffff;
  line-height: 1.56;
  outline: none;
  transition:
    border-color 0.16s ease,
    box-shadow 0.16s ease,
    background 0.16s ease;
}

textarea::placeholder {
  color: var(--soft);
}

textarea:focus,
select:focus,
button:focus-visible,
.group-button:focus-visible {
  border-color: var(--focus);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.16);
}

.primary-button {
  padding: 0 17px;
  color: #ffffff;
  background: var(--accent);
  font-size: 14px;
  font-weight: 760;
}

.primary-button:hover {
  background: var(--accent-strong);
}

.quiet-button {
  padding: 0 13px;
  color: #414854;
  background: #ffffff;
  border-color: var(--line);
  font-size: 13px;
  font-weight: 680;
}

.quiet-button:hover {
  border-color: var(--line-strong);
  background: var(--surface-muted);
}

.danger-button {
  padding: 0 13px;
  color: var(--danger);
  background: #ffffff;
  border-color: #f1cbc6;
  font-size: 13px;
  font-weight: 680;
}

.danger-button:hover {
  background: var(--danger-soft);
}

#deleteGroupButton {
  padding: 0 8px;
  color: var(--muted);
  background: transparent;
  border-color: transparent;
  font-weight: 640;
}

#deleteGroupButton:hover {
  color: var(--danger);
  background: var(--danger-soft);
}

.icon-button {
  width: 36px;
  padding: 0;
  color: #ffffff;
  background: var(--ink);
  font-size: 20px;
  line-height: 1;
}

.icon-button:hover {
  background: #2b313a;
}

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

.memo-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  column-gap: 16px;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  transition:
    border-color 0.16s ease,
    box-shadow 0.16s ease,
    background 0.16s ease;
}

.memo-item:hover {
  border-color: var(--line-strong);
  box-shadow: 0 10px 26px rgba(23, 26, 31, 0.06);
}

.memo-item.completed {
  background: #fbfcfd;
}

.item-main {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.todo-text,
.question-text,
.answer-text {
  margin: 0;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
  line-height: 1.58;
}

.todo-text {
  font-size: 15px;
}

.question-text {
  font-size: 15px;
  font-weight: 780;
}

.answer-text {
  color: #49515d;
  font-size: 14px;
}

.answer-placeholder {
  color: var(--soft);
}

.completed .inline-edit-trigger.todo-text,
.completed .inline-edit-trigger.question-text {
  color: var(--soft);
  text-decoration: line-through;
  text-decoration-thickness: 1.5px;
}

.completed .inline-edit-trigger.answer-text {
  color: var(--muted);
}

.inline-edit-trigger {
  width: 100%;
  min-height: 28px;
  border: 1px solid transparent;
  border-radius: 7px;
  padding: 3px 5px;
  color: inherit;
  background: transparent;
  cursor: text;
  font: inherit;
  text-align: left;
}

.inline-edit-trigger:hover {
  background: var(--surface-muted);
}

.inline-edit-input {
  width: 100%;
  min-height: 42px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 6px 8px;
  color: var(--ink);
  background: #ffffff;
  font: inherit;
  line-height: 1.58;
  outline: none;
}

.inline-edit-input.answer-text {
  color: #49515d;
}

.inline-edit-input::placeholder {
  color: var(--soft);
}

.item-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
  justify-content: flex-end;
}

.item-actions button {
  min-height: 30px;
}

.item-actions .quiet-button,
.item-actions .danger-button {
  padding: 0 6px;
  color: var(--muted);
  background: transparent;
  border-color: transparent;
  font-size: 13px;
  font-weight: 620;
}

.item-actions .quiet-button:hover {
  color: var(--ink);
  background: var(--surface-muted);
}

.item-actions .danger-button:hover {
  color: var(--danger);
  background: var(--danger-soft);
}

.move-control {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  margin-left: auto;
}

.move-select {
  max-width: 128px;
  min-height: 30px;
  border: 1px solid transparent;
  border-radius: 7px;
  padding: 0 24px 0 7px;
  color: var(--muted);
  background: transparent;
  font-size: 13px;
  font-weight: 620;
  outline: none;
  cursor: pointer;
}

.move-select:hover {
  color: var(--ink);
  background: var(--surface-muted);
}

.move-select:focus {
  border-color: transparent;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.move-select:disabled {
  color: var(--soft);
  background: transparent;
  cursor: default;
}

.empty-state {
  margin: 26px 0 10px;
  color: var(--muted);
  font-size: 14px;
  text-align: center;
}

.group-dialog {
  width: min(430px, calc(100vw - 28px));
  border: 0;
  border-radius: 8px;
  padding: 0;
  background: transparent;
}

.group-dialog::backdrop {
  background: rgba(16, 24, 40, 0.36);
  backdrop-filter: blur(4px);
}

.group-dialog-card {
  display: grid;
  gap: 16px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 24px 70px rgba(16, 24, 40, 0.24);
}

.group-dialog-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.group-dialog-heading h2,
.group-dialog-heading p {
  margin: 0;
}

.group-dialog-heading h2 {
  color: var(--ink);
  font-size: 18px;
  line-height: 1.2;
}

.group-dialog-heading p {
  margin-top: 5px;
  color: var(--muted);
  font-size: 13px;
}

.dialog-close-button {
  width: 32px;
  min-height: 32px;
  border: 1px solid transparent;
  border-radius: 7px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
}

.dialog-close-button:hover {
  color: var(--ink);
  background: var(--surface-muted);
}

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

.group-name-input {
  width: 100%;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  color: var(--ink);
  background: #ffffff;
  outline: none;
}

.group-name-input:focus {
  border-color: var(--focus);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.16);
}

.dialog-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.field-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 12px;
}

.daybook-view {
  display: grid;
  gap: 16px;
}

.daybook-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.section-kicker {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
}

.daybook-heading h2,
.daybook-heading p,
.summary-section h3,
.daily-progress h3 {
  margin: 0;
}

.daybook-heading h2 {
  color: var(--ink);
  font-size: 22px;
  line-height: 1.2;
}

.daybook-heading p:not(.section-kicker) {
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
}

.daybook-date-tools {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.date-input,
.daybook-value-input,
.daybook-title-input,
.daybook-field-name-input {
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 0 10px;
  color: var(--ink);
  background: #ffffff;
  outline: none;
}

.date-input:focus,
.daybook-value-input:focus,
.daybook-title-input:focus,
.daybook-field-name-input:focus,
.daybook-text-input:focus {
  border-color: var(--focus);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.16);
}

.period-tabs {
  display: inline-grid;
  grid-template-columns: repeat(4, minmax(58px, 1fr));
  width: fit-content;
  gap: 3px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #eef1f5;
}

.period-button {
  min-height: 32px;
  border: 0;
  border-radius: 6px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  font-size: 13px;
  font-weight: 760;
}

.period-button.active {
  color: var(--ink);
  background: #ffffff;
  box-shadow: 0 1px 3px rgba(23, 26, 31, 0.08);
}

.daybook-board {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px;
  align-items: start;
}

.daybook-section,
.summary-section,
.daily-progress {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.daybook-section {
  min-width: 0;
  padding: 12px;
}

.daybook-section-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.daybook-section-title-wrap {
  min-width: 0;
}

.daybook-section-title {
  max-width: 100%;
  min-height: 28px;
  border: 0;
  border-radius: 6px;
  padding: 2px 4px;
  color: #2c3138;
  background: transparent;
  cursor: text;
  font-size: 15px;
  font-weight: 780;
  overflow-wrap: anywhere;
  text-align: left;
}

.daybook-section-title:hover,
.daybook-field-name:hover {
  background: var(--surface-muted);
}

.daybook-title-input {
  width: min(260px, 100%);
  font-weight: 760;
}

.daybook-section-actions,
.daybook-field-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 4px;
  justify-content: flex-end;
}

.daybook-section-actions .quiet-button,
.daybook-section-actions .danger-button,
.daybook-field-actions .quiet-button,
.daybook-field-actions .danger-button {
  min-height: 28px;
  padding: 0 5px;
  color: var(--muted);
  background: transparent;
  border-color: transparent;
  font-size: 12px;
  font-weight: 620;
}

.daybook-section-actions .quiet-button:hover,
.daybook-field-actions .quiet-button:hover {
  color: var(--ink);
  background: var(--surface-muted);
}

.daybook-section-actions .danger-button:hover,
.daybook-field-actions .danger-button:hover {
  color: var(--danger);
  background: var(--danger-soft);
}

.daybook-field-list {
  display: grid;
  gap: 8px;
  padding-top: 10px;
}

.daybook-field {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: start;
  min-height: 34px;
}

.daybook-field-shell {
  min-width: 0;
}

.daybook-check-control {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  gap: 7px;
  align-items: start;
  min-height: 30px;
  color: var(--ink);
}

.daybook-check-control input {
  width: 17px;
  height: 17px;
  margin: 5px 0 0;
  accent-color: var(--accent);
}

.daybook-field-label-row {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 7px;
  margin-bottom: 6px;
}

.daybook-field-name {
  min-width: 0;
  min-height: 28px;
  border: 0;
  border-radius: 6px;
  padding: 2px 4px;
  color: var(--ink);
  background: transparent;
  cursor: text;
  font-size: 14px;
  font-weight: 680;
  line-height: 1.45;
  overflow-wrap: anywhere;
  text-align: left;
}

.daybook-field-name-input {
  width: min(260px, 100%);
  min-width: 0;
  font-size: 14px;
}

.daybook-unit {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 12px;
}

.daybook-text-input {
  width: 100%;
  min-height: 54px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 8px 9px;
  color: var(--ink);
  background: #ffffff;
  line-height: 1.5;
  outline: none;
  resize: vertical;
}

.daybook-value-input {
  width: min(150px, 100%);
}

.daybook-footer-actions {
  display: flex;
  justify-content: flex-start;
}

.summary-cards {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.summary-card {
  display: grid;
  gap: 8px;
  min-height: 88px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 13px;
  background: var(--surface);
}

.summary-card span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 720;
}

.summary-card strong {
  color: var(--ink);
  font-size: 24px;
  line-height: 1.1;
}

.summary-section-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.summary-section {
  padding: 12px;
}

.summary-section h3,
.daily-progress h3 {
  color: #2c3138;
  font-size: 15px;
  line-height: 1.25;
}

.summary-rows {
  display: grid;
  gap: 7px;
  margin-top: 10px;
}

.summary-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  min-height: 24px;
  color: var(--muted);
  font-size: 13px;
}

.summary-row span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.summary-row strong {
  flex: 0 0 auto;
  color: var(--ink);
  font-weight: 760;
}

.daily-progress {
  margin-top: 12px;
  padding: 12px;
}

.daily-progress-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(128px, 1fr));
  gap: 7px;
  margin-top: 10px;
}

.daily-progress-row {
  display: flex;
  min-height: 38px;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 0 9px;
  color: var(--ink);
  background: #ffffff;
  cursor: pointer;
  font-size: 13px;
}

.daily-progress-row:hover {
  border-color: var(--line-strong);
  background: var(--surface-muted);
}

.daily-progress-row span:last-child {
  color: var(--muted);
  font-size: 12px;
}

.hidden {
  display: none !important;
}

@media (max-width: 760px) {
  body {
    background:
      linear-gradient(180deg, #ffffff 0, #f8f9fb 220px, var(--bg) 420px),
      var(--bg);
  }

  .app-shell {
    padding: 18px 12px max(18px, env(safe-area-inset-bottom));
  }

  .topbar {
    display: grid;
    grid-template-columns: 1fr;
    align-items: stretch;
    gap: 14px;
    padding-bottom: 14px;
  }

  .topbar h1 {
    font-size: 26px;
  }

  .module-tabs {
    width: 100%;
  }

  .period-tabs {
    width: 100%;
  }

  .workspace {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .groups-panel,
  .content-panel {
    box-shadow: 0 10px 26px rgba(23, 26, 31, 0.05);
  }

  .groups-panel {
    position: static;
    padding: 12px;
  }

  .group-list {
    display: grid;
    gap: 8px;
    margin: 12px 0 0;
  }

  .group-button {
    min-width: 0;
  }

  .content-panel {
    padding: 14px;
  }

  .content-heading {
    display: grid;
  }

  .content-heading h2 {
    font-size: 18px;
  }

  textarea {
    min-height: 86px;
  }

  .memo-item {
    grid-template-columns: 1fr;
    padding: 13px;
  }

  .group-actions,
  .item-actions {
    justify-content: stretch;
  }

  .group-actions button,
  .item-actions button,
  .dialog-footer button,
  .primary-button {
    flex: 1 1 auto;
  }

  .dialog-footer {
    justify-content: stretch;
  }

  .move-control {
    flex: 0 1 auto;
    min-width: 0;
  }

  .move-select {
    max-width: 128px;
  }

  .daybook-heading {
    display: grid;
  }

  .daybook-date-tools {
    justify-content: stretch;
  }

  .daybook-date-tools .date-input,
  .daybook-date-tools .quiet-button {
    flex: 1 1 auto;
  }

  .daybook-board,
  .summary-cards,
  .summary-section-list {
    grid-template-columns: 1fr;
  }

  .daybook-section-heading {
    grid-template-columns: 1fr;
  }

  .daybook-section-heading {
    display: grid;
  }

  .daybook-section-actions {
    justify-content: flex-start;
  }

  .daybook-field-actions {
    justify-content: flex-end;
  }

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

  .daily-progress-list {
    grid-template-columns: 1fr;
  }
}
