:root {
  --ink: #25332d;
  --muted: #6f7d76;
  --paper: #fbfaf5;
  --white: #ffffff;
  --line: #dfe5df;
  --green: #176451;
  --green-dark: #104b3d;
  --green-soft: #e5f1ec;
  --coral: #d8785e;
  --coral-soft: #faeee9;
  --yellow: #f2cc73;
  --shadow: 0 18px 48px rgba(45, 64, 55, 0.1);
}

* { box-sizing: border-box; }
.hidden { display: none !important; }

html { background: var(--paper); }

body {
  margin: 0;
  background:
    radial-gradient(circle at 8% 0%, rgba(242, 204, 115, 0.12), transparent 22rem),
    var(--paper);
  color: var(--ink);
  font-family: "Yu Gothic UI", "Hiragino Sans", "Noto Sans JP", sans-serif;
}

button, input, select, textarea { font: inherit; }
button, select { cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid rgba(23, 100, 81, 0.24);
  outline-offset: 2px;
}

.app-shell { min-height: 100vh; }
.topbar {
  min-height: 82px;
  padding: 14px clamp(20px, 4vw, 64px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  background: rgba(255, 255, 255, 0.88);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(16px);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand, .person-line, .header-actions { display: flex; align-items: center; }
.brand { gap: 13px; }
.brand-mark, .large-avatar, .avatar {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 50%;
  font-weight: 800;
}
.brand-mark {
  width: 48px;
  height: 48px;
  background: var(--green);
  color: white;
  box-shadow: inset 0 0 0 5px rgba(255, 255, 255, 0.12);
  font-family: Georgia, serif;
  font-size: 23px;
}
.brand h1, .control-heading h2, .section-title h2, .editor-header h2, .modal h2, .editor-empty h2 {
  margin: 0;
  letter-spacing: 0.02em;
}
.brand h1 { font-size: 19px; }
.eyebrow {
  margin: 0 0 3px;
  color: var(--green);
  font-family: Arial, sans-serif;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.18em;
}
.header-actions { gap: 12px; }
.logout-form { margin: 0; }
.logout-button { padding: 8px 5px; border: 0; background: transparent; color: var(--muted); font-size: 11px; }
.privacy-badge {
  color: var(--green);
  font-size: 12px;
  font-weight: 700;
}
.privacy-badge span { color: #4da687; font-size: 8px; margin-right: 5px; }
.secondary-button, .primary-button, .compact-form button, .empty-sidebar button {
  border: 0;
  border-radius: 10px;
  font-weight: 700;
}
.secondary-button {
  padding: 11px 16px;
  color: var(--green-dark);
  background: var(--green-soft);
}

.control-panel {
  padding: 24px clamp(20px, 4vw, 64px);
  display: grid;
  grid-template-columns: minmax(190px, 1.3fr) repeat(3, minmax(130px, 0.85fr)) minmax(110px, 0.6fr);
  align-items: end;
  gap: 16px;
  background: var(--green-dark);
  color: white;
}
.control-heading h2 { font-size: 25px; }
.control-heading .eyebrow { color: #91c5b4; }
.control-panel label > span, .structure-column label > span, .child-form label > span {
  display: block;
  margin: 0 0 7px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
}
.control-panel select, .structure-column select, .compact-form input, .child-form input {
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 9px;
  padding: 11px 12px;
  background: rgba(255, 255, 255, 0.1);
  color: white;
}
.control-panel option { color: var(--ink); }
.date-selects { display: grid; grid-template-columns: 1.2fr 0.8fr; gap: 6px; }
.completion-card {
  min-height: 64px;
  padding: 10px 15px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-left: 1px solid rgba(255, 255, 255, 0.2);
}
.completion-card span { font-size: 11px; color: #b8d6cd; }
.completion-card strong { font-family: Georgia, serif; font-size: 28px; }
.completion-card small { font: 12px "Yu Gothic UI", sans-serif; color: #b8d6cd; }

.notice { margin: 16px clamp(20px, 4vw, 64px) 0; padding: 12px 16px; border-radius: 10px; font-size: 13px; }
.error-notice { color: #8b321f; background: #fce6df; border: 1px solid #efc2b6; }
.success-notice { color: var(--green-dark); background: var(--green-soft); border: 1px solid #bfddd2; }

.workspace {
  width: min(1480px, 100%);
  margin: 0 auto;
  padding: 30px clamp(20px, 4vw, 64px) 64px;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}
.child-sidebar, .editor-panel {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 10px 30px rgba(45, 64, 55, 0.055);
}
.child-sidebar { padding: 20px 14px 14px; position: sticky; top: 110px; }
.section-title { display: flex; align-items: center; justify-content: space-between; padding: 0 8px 16px; }
.section-title h2 { font-size: 18px; }
.section-title > span { padding: 5px 9px; border-radius: 999px; background: var(--paper); color: var(--muted); font-size: 11px; }
.child-list { display: grid; gap: 7px; }
.child-button {
  width: 100%;
  padding: 11px 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
  border: 1px solid transparent;
  border-radius: 11px;
  background: transparent;
  color: var(--ink);
}
.child-button:hover { background: #f6f8f5; }
.child-button.active { background: var(--green-soft); border-color: #c8ded5; }
.avatar { width: 38px; height: 38px; background: var(--coral-soft); color: #a44d37; font-size: 14px; }
.child-button:nth-child(3n + 2) .avatar { background: #edf0fa; color: #59699e; }
.child-button:nth-child(3n + 3) .avatar { background: #f9f1d9; color: #8b6a18; }
.child-button-copy { display: grid; gap: 2px; flex: 1; }
.child-button-copy strong { font-size: 14px; }
.child-button-copy small, .roster-row small { color: var(--muted); font-size: 11px; }
.status-dot { width: 8px; height: 8px; display: inline-block; border: 1px solid #aeb9b3; border-radius: 50%; background: white; }
.status-dot.saved { border-color: var(--green); background: var(--green); box-shadow: 0 0 0 3px var(--green-soft); }
.legend { margin-top: 16px; padding: 14px 8px 2px; display: flex; gap: 15px; border-top: 1px solid var(--line); color: var(--muted); font-size: 10px; }
.legend span { display: flex; gap: 7px; align-items: center; }
.empty-sidebar { padding: 30px 16px; text-align: center; color: var(--muted); }
.empty-sidebar > span { display: grid; place-items: center; width: 46px; height: 46px; margin: auto; border-radius: 50%; background: var(--green-soft); color: var(--green); font-size: 24px; }
.empty-sidebar p { font-size: 12px; line-height: 1.7; }
.empty-sidebar button { padding: 9px 12px; color: var(--green); background: transparent; }

.editor-panel { min-height: 620px; overflow: hidden; }
.editor-header {
  padding: 24px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(105deg, #fff 55%, #f2f7f4);
}
.person-line { gap: 14px; }
.large-avatar { width: 52px; height: 52px; background: var(--coral-soft); color: #a44d37; font-size: 19px; }
.editor-header h2 { font-size: 23px; }
.editor-header h2 small { margin-left: 3px; color: var(--muted); font-size: 12px; font-weight: 500; }
.child-meta { margin: 8px 0 0 66px; color: var(--muted); font-size: 11px; }
.child-meta span { color: #bdc7c1; }
.source-badge { max-width: 280px; padding: 10px 13px; display: flex; align-items: center; gap: 10px; border: 1px solid #ecd899; border-radius: 10px; background: #fff9e9; color: #7b5d10; }
.source-badge > span { font-size: 19px; }
.source-badge div { display: grid; gap: 1px; }
.source-badge small { font-size: 9px; letter-spacing: 0.08em; }
.source-badge strong { font-size: 11px; }
.form-stack { padding: 24px 28px 12px; display: grid; gap: 15px; background-image: linear-gradient(rgba(23, 100, 81, 0.018) 1px, transparent 1px); background-size: 100% 28px; }
.field-card { display: grid; grid-template-columns: 42px minmax(0, 1fr); gap: 13px; }
.field-number { padding-top: 7px; color: #a6b3ad; font: italic 14px Georgia, serif; }
.field-content { min-width: 0; }
.field-heading { margin-bottom: 7px; display: flex; justify-content: space-between; align-items: end; gap: 12px; }
.field-heading div { display: grid; gap: 2px; }
.field-heading span { font-size: 13px; font-weight: 800; }
.field-heading small { color: var(--muted); font-size: 10px; }
.field-heading em { color: #9aa7a0; font-size: 9px; font-style: normal; white-space: nowrap; }
.field-card textarea {
  width: 100%;
  resize: vertical;
  padding: 13px 15px;
  border: 1px solid #d8e0db;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--ink);
  font-size: 13px;
  line-height: 1.8;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.field-card textarea:hover { border-color: #b8c8c0; }
.field-card textarea:focus { border-color: var(--green); box-shadow: 0 0 0 3px var(--green-soft); outline: none; }
.save-bar { padding: 18px 28px 22px; display: flex; justify-content: space-between; align-items: center; gap: 20px; border-top: 1px solid var(--line); background: #fcfdfb; }
.save-bar p { margin: 0; color: var(--muted); font-size: 11px; }
.save-bar p span { display: inline-grid; place-items: center; width: 16px; height: 16px; margin-right: 6px; border: 1px solid #b6c0ba; border-radius: 50%; font: 10px Georgia, serif; }
.primary-button { padding: 12px 20px; background: var(--green); color: white; box-shadow: 0 8px 20px rgba(23, 100, 81, 0.18); }
.primary-button:hover { background: var(--green-dark); }
.primary-button:disabled { opacity: 0.6; cursor: wait; }
.editor-empty { min-height: 620px; padding: 70px 30px; display: grid; place-items: center; align-content: center; text-align: center; }
.editor-empty h2 { margin-top: 7px; font-size: 24px; }
.editor-empty > p:last-child { max-width: 520px; margin: 14px auto 0; color: var(--muted); font-size: 13px; line-height: 1.9; }
.notebook-shape { width: 150px; height: 98px; margin-bottom: 25px; padding: 18px 20px; display: grid; gap: 8px; border: 1px solid #c9d8d1; border-radius: 10px; background: #f7fbf8; box-shadow: 10px 10px 0 var(--green-soft); transform: rotate(-2deg); }
.notebook-shape span { height: 1px; display: flex; align-items: center; gap: 8px; color: #9bad9f; font: 9px Georgia, serif; }
.notebook-shape span::after { content: ""; height: 1px; flex: 1; background: #cbd8d1; }

.modal-backdrop { position: fixed; inset: 0; z-index: 50; padding: 24px; display: grid; place-items: center; background: rgba(23, 38, 31, 0.58); backdrop-filter: blur(5px); }
.modal { width: min(920px, 100%); max-height: calc(100vh - 48px); overflow: auto; border-radius: 18px; background: white; box-shadow: var(--shadow); }
.modal-header { padding: 24px 28px; display: flex; justify-content: space-between; gap: 20px; border-bottom: 1px solid var(--line); }
.modal-header h2 { font-size: 24px; }
.modal-header > div > p:last-child { margin: 7px 0 0; color: var(--muted); font-size: 12px; }
.close-button { width: 38px; height: 38px; border: 0; border-radius: 50%; background: #f1f3f1; color: var(--ink); font-size: 25px; }
.modal-grid { display: grid; grid-template-columns: 0.75fr 1.4fr; }
.structure-column, .roster-column { padding: 24px 28px 30px; }
.structure-column { border-right: 1px solid var(--line); background: #f8faf7; }
.structure-column h3, .roster-column h3, .child-form h3 { margin: 0 0 16px; font-size: 15px; }
.structure-column label { display: block; margin-bottom: 14px; }
.structure-column select, .compact-form input, .child-form input { border-color: #d8dfda; background: white; color: var(--ink); }
.structure-column details { margin-top: 22px; border-top: 1px solid var(--line); }
.structure-column summary { padding: 17px 0 10px; color: var(--green); font-size: 12px; font-weight: 800; }
.compact-form { margin: 8px 0; display: grid; grid-template-columns: 1fr 64px auto; gap: 6px; }
.compact-form + .compact-form { grid-template-columns: 1fr auto; }
.compact-form input { min-width: 0; padding: 9px; font-size: 11px; }
.compact-form button { padding: 8px 9px; background: var(--green-soft); color: var(--green-dark); font-size: 10px; }
.roster-heading { display: flex; justify-content: space-between; }
.roster-heading h3 { margin-bottom: 2px; font-size: 18px; }
.roster-heading p { margin: 0; color: var(--muted); font-size: 11px; }
.roster-list { margin: 15px 0 24px; display: grid; gap: 7px; }
.roster-row { padding: 9px; display: grid; grid-template-columns: 34px 1fr auto auto; align-items: center; gap: 9px; border: 1px solid var(--line); border-radius: 9px; }
.small-avatar { width: 34px; height: 34px; font-size: 12px; }
.roster-row > div { display: grid; gap: 1px; }
.roster-row strong { font-size: 12px; }
.roster-row button { padding: 6px 8px; border: 0; border-radius: 7px; background: var(--green-soft); color: var(--green); font-size: 10px; }
.roster-row .archive-button { background: transparent; color: #a75743; }
.child-form { padding: 18px; border-radius: 12px; background: var(--paper); }
.child-form label { display: block; margin-bottom: 11px; }
.child-form input { padding: 10px 11px; font-size: 12px; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; }
.form-actions > button:not(.primary-button) { border: 0; background: transparent; color: var(--muted); font-size: 11px; }
.child-form .primary-button { padding: 10px 14px; font-size: 11px; }

.loading-screen { min-height: 100vh; display: grid; place-items: center; align-content: center; gap: 12px; color: var(--green); }
.loading-mark { width: 58px; height: 58px; display: grid; place-items: center; border-radius: 50%; background: var(--green); color: white; font: 27px Georgia, serif; animation: breathe 1.7s ease-in-out infinite; }
.loading-screen p { font-size: 12px; font-weight: 700; letter-spacing: 0.08em; }
@keyframes breathe { 50% { transform: scale(1.08); box-shadow: 0 0 0 12px var(--green-soft); } }

.auth-shell { min-height: 100vh; padding: 28px; display: grid; place-items: center; }
.auth-card { width: min(470px, 100%); padding: 34px; border: 1px solid var(--line); border-radius: 18px; background: white; box-shadow: var(--shadow); }
.auth-brand { margin-bottom: 28px; display: flex; align-items: center; gap: 14px; }
.auth-card h1 { margin: 0; font-size: 23px; }
.auth-card > p, .setup-note { color: var(--muted); font-size: 13px; line-height: 1.8; }
.auth-form { margin-top: 24px; display: grid; gap: 16px; }
.auth-form label { display: grid; gap: 7px; font-size: 12px; font-weight: 700; }
.auth-form input { width: 100%; padding: 12px 13px; border: 1px solid #d8dfda; border-radius: 9px; background: white; color: var(--ink); }
.auth-form .primary-button { width: 100%; margin-top: 5px; }
.setup-code { padding: 14px; overflow-x: auto; border-radius: 9px; background: #f2f4f1; color: #45524c; font: 11px/1.7 Consolas, monospace; }
.auth-error { margin: 16px 0 0; padding: 11px 13px; border-radius: 9px; background: #fce6df; color: #8b321f; font-size: 12px; }
.noscript-notice { margin: 30px; padding: 18px; border: 1px solid #efc2b6; border-radius: 10px; background: #fce6df; }

@media (max-width: 960px) {
  .control-panel { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .control-heading { grid-column: 1 / -1; }
  .completion-card { border-left: 0; }
  .workspace { grid-template-columns: 220px minmax(0, 1fr); padding-inline: 18px; }
  .editor-header, .save-bar { align-items: flex-start; flex-direction: column; }
  .save-bar .primary-button { width: 100%; }
  .modal-grid { grid-template-columns: 1fr; }
  .structure-column { border-right: 0; border-bottom: 1px solid var(--line); }
}

@media (max-width: 700px) {
  .topbar { position: static; padding: 12px 16px; }
  .brand .eyebrow, .privacy-badge { display: none; }
  .brand h1 { font-size: 16px; }
  .brand-mark { width: 40px; height: 40px; }
  .secondary-button { padding: 9px 10px; font-size: 11px; }
  .control-panel { padding: 20px 16px; grid-template-columns: 1fr 1fr; }
  .completion-card { min-height: 50px; }
  .workspace { display: block; padding: 18px 12px 44px; }
  .child-sidebar { position: static; margin-bottom: 14px; }
  .child-list { display: flex; overflow-x: auto; padding-bottom: 5px; }
  .child-button { min-width: 164px; }
  .legend { display: none; }
  .editor-header, .form-stack, .save-bar { padding-inline: 17px; }
  .source-badge { max-width: 100%; }
  .field-card { grid-template-columns: 26px minmax(0, 1fr); gap: 5px; }
  .field-heading small { display: none; }
  .modal-backdrop { padding: 0; align-items: end; }
  .modal { max-height: 94vh; border-radius: 18px 18px 0 0; }
  .modal-header, .structure-column, .roster-column { padding-inline: 18px; }
  .roster-row { grid-template-columns: 34px 1fr auto; }
  .roster-row .archive-button { grid-column: 2 / -1; justify-self: start; padding-left: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation: none !important; transition: none !important; }
}
