
:root {
  --forest: #123f37;
  --forest-2: #20574c;
  --cream: #f7f4ed;
  --paper: #fffdf9;
  --ink: #18312c;
  --muted: #71807c;
  --line: #dce2df;
  --danger: #aa453e;
  --shadow: 0 24px 70px rgba(10, 34, 29, .18);
  font-family: Inter, Pretendard, "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { color: var(--ink); background: var(--cream); }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.brand-mark {
  display: grid;
  place-items: center;
  width: 72px;
  height: 72px;
  border-radius: 24px;
  color: white;
  background: linear-gradient(145deg, var(--forest), #2a665a);
  font-weight: 900;
  letter-spacing: .08em;
  box-shadow: 0 12px 26px rgba(18,63,55,.24);
}
.brand-mark.small {
  width: 48px;
  height: 48px;
  border-radius: 16px;
  font-size: 13px;
}
.primary {
  border: 0;
  min-height: 56px;
  padding: 13px 18px;
  border-radius: 16px;
  color: white;
  background: var(--forest);
  font-weight: 850;
}
.primary:hover { background: var(--forest-2); }
.stack { display: grid; gap: 18px; }
label { display: grid; gap: 8px; font-size: 14px; font-weight: 800; }
input, textarea, select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 15px;
  padding: 14px 16px;
  color: var(--ink);
  background: white;
  outline: none;
}
input:focus, textarea:focus, select:focus {
  border-color: #648c83;
  box-shadow: 0 0 0 5px rgba(32,87,76,.10);
}
textarea { min-height: 130px; resize: vertical; }
.form-note { margin: 0; color: var(--muted); font-size: 12px; text-align: center; }
.error {
  margin: 0;
  padding: 10px 12px;
  color: var(--danger);
  border-radius: 12px;
  background: rgba(170,69,62,.08);
  text-align: center;
  font-size: 13px;
}

/* Login */
.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 10% 10%, rgba(168,122,66,.10), transparent 26%),
    linear-gradient(145deg, #f8f5ef, #eceae3);
}
.auth-card {
  width: min(640px, 100%);
  padding: 52px 60px 48px;
  border: 1px solid rgba(18,63,55,.11);
  border-radius: 34px;
  background: rgba(255,253,249,.97);
  box-shadow: var(--shadow);
}
.auth-brand p {
  margin: 24px 0 22px;
  color: #9a7040;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: .18em;
}
.auth-title {
  padding: 34px 0 30px;
  border-top: 1px solid rgba(18,63,55,.13);
  text-align: center;
}
.auth-title h1 {
  margin: 0;
  font-size: clamp(39px, 7vw, 56px);
  letter-spacing: -.06em;
}
.auth-title strong {
  display: block;
  margin-top: 13px;
  font-size: clamp(28px, 5vw, 38px);
}
.auth-title span {
  display: block;
  margin-top: 7px;
  color: #315d54;
  font-size: clamp(20px, 3.5vw, 27px);
  font-weight: 700;
}

/* Search portal */
.portal {
  position: relative;
  min-height: 100vh;
  overflow: hidden;
  color: white;
  background-image: url("./hero-family-coast.jpg");
  background-size: cover;
  background-position: center;
}
.portal-shade {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(5,28,24,.40) 0%, rgba(5,28,24,.05) 35%, rgba(5,28,24,.18) 72%, rgba(5,28,24,.65) 100%),
    radial-gradient(circle at center, rgba(255,244,221,.02), rgba(5,28,24,.15));
}
.portal-header {
  position: relative;
  z-index: 3;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  padding: 28px 38px;
}
.portal-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0;
  border: 0;
  color: white;
  background: transparent;
}
.brand-name {
  font-size: 13px;
  font-weight: 900;
  letter-spacing: .16em;
  text-shadow: 0 2px 10px rgba(0,0,0,.25);
}
.portal-tools { display: flex; align-items: center; gap: 10px; }
.user-name { margin-right: 5px; font-size: 13px; font-weight: 750; text-shadow: 0 2px 8px rgba(0,0,0,.3); }
.glass-button {
  border: 1px solid rgba(255,255,255,.42);
  border-radius: 999px;
  padding: 10px 15px;
  color: white;
  background: rgba(10,45,39,.28);
  backdrop-filter: blur(12px);
  font-weight: 800;
}
.glass-button:hover { background: rgba(10,45,39,.45); }

.search-home {
  position: relative;
  z-index: 2;
  min-height: calc(100vh - 150px);
  display: grid;
  align-content: center;
  justify-items: center;
  padding: 30px 22px 160px;
  text-align: center;
}
.search-intro p {
  margin: 0 0 14px;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: .20em;
}
.search-intro h1 {
  margin: 0;
  font-size: clamp(48px, 7.2vw, 88px);
  line-height: 1.06;
  letter-spacing: -.065em;
  text-shadow: 0 4px 24px rgba(0,0,0,.24);
}
.search-intro span {
  display: block;
  margin-top: 17px;
  font-size: clamp(18px, 2.2vw, 27px);
  font-weight: 650;
  text-shadow: 0 3px 15px rgba(0,0,0,.30);
}
.main-search {
  width: min(860px, 92vw);
  min-height: 76px;
  margin-top: 38px;
  display: grid;
  grid-template-columns: 30px 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 9px 10px 9px 24px;
  border: 1px solid rgba(255,255,255,.60);
  border-radius: 999px;
  background: rgba(255,255,255,.96);
  box-shadow: 0 20px 50px rgba(5,28,24,.25);
}
.main-search svg {
  width: 25px;
  fill: none;
  stroke: #6f7c79;
  stroke-width: 2;
  stroke-linecap: round;
}
.main-search input {
  border: 0;
  padding: 10px 3px;
  background: transparent;
  box-shadow: none;
  font-size: clamp(16px, 2vw, 20px);
}
.main-search input:focus { box-shadow: none; }
.main-search button {
  align-self: stretch;
  min-width: 108px;
  border: 0;
  border-radius: 999px;
  color: white;
  background: var(--forest);
  font-weight: 900;
  font-size: 16px;
}
.quick-searches {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 9px;
  margin-top: 18px;
}
.quick-searches button {
  border: 1px solid rgba(255,255,255,.38);
  border-radius: 999px;
  padding: 8px 13px;
  color: white;
  background: rgba(9,38,33,.25);
  backdrop-filter: blur(9px);
  font-size: 12px;
}
.portal-footer {
  position: absolute;
  z-index: 2;
  left: 0;
  right: 0;
  bottom: 25px;
  text-align: center;
  font-size: 13px;
  text-shadow: 0 2px 10px rgba(0,0,0,.38);
}

/* Results */
.results-screen {
  position: absolute;
  z-index: 5;
  inset: 0;
  padding: 98px 30px 30px;
  overflow: auto;
  color: var(--ink);
  background: rgba(241,239,232,.94);
  backdrop-filter: blur(18px);
}
.results-panel {
  width: min(1120px, 100%);
  min-height: calc(100vh - 128px);
  margin: 0 auto;
  padding: 32px;
  border-radius: 30px;
  background: rgba(255,253,249,.96);
  box-shadow: var(--shadow);
}
.results-header {
  display: grid;
  grid-template-columns: 1fr minmax(300px, 470px);
  align-items: end;
  gap: 30px;
  padding-bottom: 25px;
  border-bottom: 1px solid var(--line);
}
.results-header p { margin: 18px 0 5px; color: #907147; font-size: 12px; font-weight: 900; letter-spacing: .16em; }
.results-header h2 { margin: 0; font-size: clamp(28px, 4vw, 42px); letter-spacing: -.045em; }
.results-header span { display: block; margin-top: 7px; color: var(--muted); }
.back-button {
  padding: 0;
  border: 0;
  color: var(--forest);
  background: transparent;
  font-weight: 850;
}
.results-search {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}
.results-search button {
  border: 0;
  border-radius: 14px;
  padding: 0 18px;
  color: white;
  background: var(--forest);
  font-weight: 850;
}
.results-list {
  display: grid;
  gap: 14px;
  margin-top: 25px;
}
.result-card {
  display: grid;
  grid-template-columns: 190px 1fr;
  gap: 22px;
  min-height: 170px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: white;
}
.result-image {
  overflow: hidden;
  border-radius: 16px;
  background: linear-gradient(135deg,#dbe8e2,#efe8db);
  display: grid;
  place-items: center;
  color: var(--forest);
  font-size: 38px;
}
.result-image img { width: 100%; height: 100%; object-fit: cover; }
.result-content { padding: 8px 8px 8px 0; }
.result-meta { display: flex; gap: 8px; flex-wrap: wrap; color: var(--muted); font-size: 12px; }
.result-tag { padding: 5px 8px; border-radius: 999px; color: var(--forest); background: #e8efec; font-weight: 850; }
.result-content h3 { margin: 12px 0 8px; font-size: 21px; }
.result-content p { margin: 0; color: #64736f; line-height: 1.65; }
.result-content button {
  margin-top: 13px;
  padding: 0;
  border: 0;
  color: var(--forest);
  background: transparent;
  font-weight: 850;
}
.empty {
  padding: 70px 20px;
  border: 1px dashed #b9c6c1;
  border-radius: 22px;
  color: var(--muted);
  text-align: center;
}

/* Modal and admin */
.modal-backdrop {
  position: fixed;
  z-index: 30;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 22px;
  color: var(--ink);
  background: rgba(4,22,19,.70);
  backdrop-filter: blur(10px);
}
.admin-modal {
  width: min(950px, 100%);
  max-height: 92vh;
  overflow: auto;
  padding: 28px;
  border-radius: 28px;
  background: var(--paper);
  box-shadow: var(--shadow);
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}
.modal-header p { margin: 0; color: #9a7040; font-size: 11px; font-weight: 900; letter-spacing: .18em; }
.modal-header h2 { margin: 5px 0 0; font-size: 31px; }
.modal-close {
  border: 0;
  border-radius: 12px;
  padding: 10px 14px;
  color: var(--forest);
  background: #e9efed;
  font-weight: 850;
}
.admin-tabs {
  display: flex;
  gap: 8px;
  margin: 25px 0;
  padding-bottom: 15px;
  border-bottom: 1px solid var(--line);
}
.admin-tabs button {
  border: 0;
  border-radius: 999px;
  padding: 10px 15px;
  color: var(--muted);
  background: transparent;
  font-weight: 850;
}
.admin-tabs button.active { color: white; background: var(--forest); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.full { grid-column: 1 / -1; }
.media-preview { display: grid; gap: 12px; }
.media-preview img { max-width: 100%; max-height: 260px; border-radius: 16px; object-fit: cover; }
.media-preview audio { width: 100%; }
.admin-note {
  margin: 0;
  padding: 13px;
  border-radius: 12px;
  color: #6b573b;
  background: #f4ecdf;
  font-size: 12px;
}
.admin-list, .family-list { display: grid; gap: 10px; }
.admin-row, .family-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 15px 16px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: white;
}
.admin-row strong, .family-row strong { display: block; }
.admin-row span, .family-row span { color: var(--muted); font-size: 12px; }
.delete-button {
  border: 0;
  color: var(--danger);
  background: transparent;
  font-weight: 850;
}
.compact-form { margin-top: 28px; }
.memory-modal { width: min(760px, 100%); }
.memory-modal img { width: 100%; max-height: 430px; object-fit: cover; border-radius: 18px; margin: 12px 0; }
.memory-modal audio { width: 100%; margin-top: 14px; }
.memory-story { white-space: pre-wrap; line-height: 1.8; }
.memory-lesson { padding: 16px; border-radius: 14px; background: #f4ecdf; line-height: 1.7; }

@media (max-width: 760px) {
  .auth-card { padding: 38px 26px 34px; border-radius: 27px; }
  .portal-header { padding: 18px; }
  .brand-name, .user-name { display: none; }
  .glass-button { padding: 9px 12px; font-size: 12px; }
  .search-home { min-height: calc(100vh - 90px); padding-bottom: 110px; }
  .search-intro h1 { font-size: clamp(43px, 13vw, 62px); }
  .main-search { min-height: 65px; grid-template-columns: 25px 1fr auto; padding-left: 18px; }
  .main-search button { min-width: 74px; }
  .results-screen { padding: 82px 12px 12px; }
  .results-panel { padding: 20px 15px; border-radius: 22px; }
  .results-header { grid-template-columns: 1fr; }
  .result-card { grid-template-columns: 100px 1fr; min-height: 135px; gap: 13px; }
  .result-content h3 { font-size: 17px; }
  .result-content p { font-size: 13px; }
  .form-grid { grid-template-columns: 1fr; }
  .full { grid-column: auto; }
}
@media (max-width: 480px) {
  .main-search {
    width: 95vw;
    grid-template-columns: 24px 1fr 58px;
    gap: 6px;
    padding: 7px 7px 7px 15px;
  }
  .main-search input { font-size: 14px; }
  .main-search button { min-width: 58px; font-size: 13px; }
  .result-card { grid-template-columns: 1fr; }
  .result-image { height: 170px; }
}

/* ─────────────────────────────────────────────
   v3: two-track archive, chapters, narration data
   ───────────────────────────────────────────── */
.admin-modal-wide { width: min(1080px, 100%); }
.modal-subtitle {
  display: block;
  margin-top: 7px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}
.admin-tabs-scroll {
  overflow-x: auto;
  scrollbar-width: thin;
  padding-bottom: 17px;
}
.admin-tabs-scroll button { flex: 0 0 auto; }
.track-intro {
  display: flex;
  align-items: flex-start;
  gap: 18px;
  margin-bottom: 25px;
  padding: 20px;
  border-radius: 20px;
  background: linear-gradient(135deg, #edf3f0, #f7f1e7);
}
.track-number {
  display: grid;
  place-items: center;
  flex: 0 0 52px;
  width: 52px;
  height: 52px;
  border-radius: 17px;
  color: white;
  background: var(--forest);
  font-weight: 900;
}
.track-intro h3 { margin: 2px 0 6px; font-size: 22px; }
.track-intro p { margin: 0; color: var(--muted); line-height: 1.6; }

.article-editor { min-height: 360px; line-height: 1.8; }
.file-drop {
  padding: 20px;
  border: 1px dashed #9fb4ad;
  border-radius: 18px;
  background: #f7faf8;
}
.file-drop span { font-size: 16px; }
.file-drop small { color: var(--muted); font-weight: 500; }
.file-drop input { margin-top: 4px; background: white; }
.photo-preview {
  display: grid;
  grid-template-columns: repeat(3, minmax(0,1fr));
  gap: 10px;
}
.preview-tile {
  min-width: 0;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: white;
}
.preview-tile span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 750;
  font-size: 13px;
}
.preview-tile small { color: var(--muted); }

.narration-design {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 17px;
  border: 1px solid #d8e5e0;
  border-radius: 17px;
  background: #f0f6f3;
}
.speaker-symbol { font-size: 26px; line-height: 1; }
.narration-design strong { display: block; margin-bottom: 5px; }
.narration-design p { margin: 0; color: #60746d; font-size: 13px; line-height: 1.6; }

.chapter-list { display: grid; gap: 11px; }
.chapter-row {
  display: grid;
  grid-template-columns: 50px 1fr auto;
  gap: 15px;
  align-items: center;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 17px;
  background: white;
}
.chapter-order {
  display: grid;
  place-items: center;
  width: 43px;
  height: 43px;
  border-radius: 14px;
  color: var(--forest);
  background: #e8f0ed;
  font-weight: 900;
}
.chapter-row strong { font-size: 16px; }
.chapter-row p { margin: 4px 0; color: var(--muted); font-size: 13px; line-height: 1.45; }
.chapter-row small { color: #97774e; }
.chapter-row button:disabled { color: #8b9793; cursor: default; }
.chapter-add-form {
  display: grid;
  grid-template-columns: 1fr 1.4fr auto;
  gap: 10px;
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}
.chapter-add-form .primary { min-height: auto; }

.record-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0,1fr));
  gap: 10px;
  margin-bottom: 18px;
}
.record-summary div {
  padding: 17px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: white;
}
.record-summary strong { display: block; font-size: 25px; }
.record-summary span { color: var(--muted); font-size: 12px; }
.record-admin-row > div:first-child { min-width: 0; }
.record-admin-row strong {
  margin-top: 5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.record-admin-row small { display: block; margin-top: 5px; color: var(--muted); }
.mini-type {
  display: inline-flex;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 900;
}
.mini-type.photo { color: #6e522f; background: #f1e6d5; }
.mini-type.article { color: var(--forest); background: #e4efeb; }
.admin-row-actions { display: flex; align-items: center; gap: 7px; }
.open-button {
  border: 0;
  color: var(--forest);
  background: transparent;
  font-weight: 850;
}

.backup-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.backup-card {
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: white;
}
.backup-card > span { color: #99784d; font-size: 11px; font-weight: 900; letter-spacing: .14em; }
.backup-card h3 { margin: 8px 0; font-size: 22px; }
.backup-card p { min-height: 65px; color: var(--muted); line-height: 1.6; }
.backup-file {
  margin-bottom: 10px;
  padding: 13px;
  border: 1px dashed #a7b9b3;
  border-radius: 13px;
}
.backup-file input { margin-top: 8px; }
.secondary-button {
  width: 100%;
  min-height: 52px;
  border: 1px solid #b7c8c2;
  border-radius: 14px;
  color: var(--forest);
  background: #eef4f1;
  font-weight: 850;
}
.free-operation-note {
  margin-top: 18px;
  padding: 18px;
  border-left: 4px solid #a7814e;
  border-radius: 13px;
  background: #f5eee3;
}
.free-operation-note p { margin: 6px 0 0; color: #6e5c43; line-height: 1.65; }

.photo-tag { color: #6d5130; background: #f0e5d4; }
.article-tag { color: var(--forest); background: #e4efeb; }
.article-cover {
  display: flex;
  flex-direction: column;
  gap: 9px;
  padding: 22px;
  text-align: center;
}
.article-cover span {
  display: grid;
  place-items: center;
  width: 55px;
  height: 55px;
  border: 1px solid rgba(18,63,55,.16);
  border-radius: 18px;
  background: rgba(255,255,255,.55);
  font-weight: 900;
}
.article-cover small { max-width: 150px; line-height: 1.4; font-weight: 800; }
.memory-gallery {
  display: grid;
  grid-template-columns: repeat(2, minmax(0,1fr));
  gap: 10px;
  margin: 16px 0;
}
.memory-gallery img {
  width: 100%;
  height: 300px;
  margin: 0;
  object-fit: cover;
}
.article-byline { color: var(--muted); font-size: 13px; }
.article-summary {
  margin: 22px 0;
  padding: 17px;
  border-left: 4px solid #9b7749;
  border-radius: 10px;
  color: #654f34;
  background: #f5eee3;
  font-size: 16px;
  line-height: 1.65;
}
.article-body { padding: 5px 2px 25px; line-height: 1.95; font-size: 16px; }
.narration-player {
  margin-top: 25px;
  padding: 18px;
  border-radius: 18px;
  background: #eef5f2;
}
.narration-player > p { margin: 5px 0 12px; color: var(--muted); font-size: 13px; }
.narration-player > div { display: flex; flex-wrap: wrap; gap: 9px; margin-top: 11px; }
.voice-button {
  border: 1px solid #bdcec8;
  border-radius: 999px;
  padding: 10px 14px;
  color: #72827d;
  background: white;
  font-weight: 800;
}
.voice-button.ready { color: white; border-color: var(--forest); background: var(--forest); }
.voice-button:disabled { cursor: default; opacity: .85; }

@media (max-width: 760px) {
  .photo-preview { grid-template-columns: 1fr 1fr; }
  .chapter-add-form, .backup-grid { grid-template-columns: 1fr; }
  .record-summary { grid-template-columns: 1fr 1fr; }
  .chapter-row { grid-template-columns: 42px 1fr; }
  .chapter-row > button { grid-column: 2; justify-self: start; }
  .memory-gallery { grid-template-columns: 1fr; }
  .memory-gallery img { height: auto; max-height: 420px; }
}
@media (max-width: 460px) {
  .photo-preview { grid-template-columns: 1fr; }
  .track-intro { padding: 15px; }
  .track-number { width: 44px; height: 44px; flex-basis: 44px; }
  .record-summary { grid-template-columns: 1fr 1fr; }
  .record-admin-row { align-items: flex-start; }
  .admin-row-actions { flex-direction: column; }
}


/* v4 cloud sync */
.sync-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 10px;
  border: 1px solid rgba(255,255,255,.30);
  border-radius: 999px;
  background: rgba(8,38,32,.22);
  font-size: 11px;
  font-weight: 800;
  backdrop-filter: blur(10px);
}
.sync-status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: #f3c86b; }
.sync-status.synced::before { background: #79d99e; }
.sync-status.error::before { background: #ff8a7f; }
.upload-progress {
  grid-column: 1 / -1;
  padding: 15px;
  border: 1px solid #d8e5e0;
  border-radius: 15px;
  background: #f2f7f5;
}
.upload-progress strong { display: block; margin-bottom: 8px; }
.upload-progress progress { width: 100%; height: 12px; }
.upload-progress span { display: block; margin-top: 7px; color: var(--muted); font-size: 12px; }
.preview-tile.video { background: #edf1f4; }
.preview-tile em { display: inline-flex; margin-top: 5px; padding: 3px 7px; border-radius: 999px; background: #e7efec; color: var(--forest); font-size: 10px; font-style: normal; font-weight: 800; }
.result-image video, .memory-gallery video { width: 100%; height: 100%; object-fit: cover; background: #111; }
.memory-gallery video { min-height: 280px; }
.backup-path-example { padding: 12px; border-radius: 11px; background: #eef3f1; color: #34544d; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.conflict-box { padding: 16px; border: 1px solid #e2bd79; border-radius: 15px; background: #fff5df; color: #6b5128; }
.draft-note { color: var(--muted); font-size: 12px; text-align: right; }
@media (max-width: 760px) { .sync-status { display:none; } }
