/* ============================================================
   아벨어학원 수원점 — 학생 DB
   Palette: white-gold-beige / espresso (수원점 톤)
   ============================================================ */

:root {
  --primary: #9B7B4A;
  --primary-deep: #1C1308;
  --primary-soft: rgba(155, 123, 74, 0.08);
  --primary-tint: rgba(155, 123, 74, 0.14);
  --primary-line: rgba(155, 123, 74, 0.32);

  --bg: #F4EDDF;
  --bg-soft: #F9F2E2;
  --card: #FFFFFF;
  --ivory: #F7F1E5;
  --cream: #EDE5D4;

  --text: #18120A;
  --text-soft: #5C4E3E;
  --text-mute: #9B8E82;
  --header-text: #F0E8D8;
  --header-text-mute: rgba(196, 175, 147, 0.6);

  --border: #DDD0BB;
  --border-soft: #E8DDC8;

  --success: #2E7D32;
  --danger: #C0392B;

  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 18px;

  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);

  --font-sans: 'Pretendard', -apple-system, BlinkMacSystemFont,
               'Apple SD Gothic Neo', system-ui, 'Segoe UI', Roboto, sans-serif;
  --font-mono: ui-monospace, 'SF Mono', 'Cascadia Code', Menlo, Consolas, monospace;

  --max-w: 720px;
}

*, *::before, *::after { box-sizing: border-box; }
html, body, h1, h2, h3, p, ul, ol, dl, form, pre { margin: 0; padding: 0; }

/* HTML hidden attribute가 author CSS의 display 규칙에 밀리지 않도록 강제 */
[hidden] { display: none !important; }

button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; -webkit-tap-highlight-color: transparent; }
input { font: inherit; color: inherit; }
ul { list-style: none; }
a { color: inherit; }

body {
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  letter-spacing: -0.005em;
  min-height: 100vh;
  padding-bottom: calc(72px + env(safe-area-inset-bottom));
}

/* ============================================================
   Topbar
   ============================================================ */
.topbar {
  background: var(--primary-deep);
  color: var(--header-text);
  position: sticky;
  top: 0;
  z-index: 30;
  padding-top: env(safe-area-inset-top);
}
.tb-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
}
.tb-left { display: flex; align-items: center; gap: 12px; }

.tb-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: rgba(196, 175, 147, 0.1);
  border: 1px solid rgba(196, 175, 147, 0.18);
  font-weight: 700;
  font-size: 14px;
}

.tb-text { line-height: 1.25; }
.tb-brand {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.3em;
  padding-left: 0.3em;
}
.tb-loc {
  margin-top: 3px;
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.16em;
  color: var(--header-text-mute);
}

.tb-refresh {
  width: 36px;
  height: 36px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--header-text);
  opacity: 0.78;
  transition: opacity 0.2s var(--ease), background 0.2s var(--ease);
}
.tb-refresh:hover { opacity: 1; background: rgba(255, 255, 255, 0.06); }
.tb-refresh.is-spin svg { animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================
   Controls — search & chips
   ============================================================ */
.controls {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 14px 18px 0;
}

.search {
  position: relative;
  background: var(--card);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-md);
  display: flex;
  align-items: center;
  padding: 0 14px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.search:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(155, 123, 74, 0.14);
}
.search-ico { color: var(--text-mute); flex-shrink: 0; }
.search input {
  flex: 1;
  padding: 13px 10px;
  border: 0;
  outline: 0;
  background: transparent;
  font-size: 15.5px;
  letter-spacing: -0.005em;
}
.search input::placeholder { color: var(--text-mute); }
.search-clear {
  width: 26px;
  height: 26px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-mute);
  background: var(--border-soft);
}
.search-clear:hover { color: var(--text); }

.chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 12px 0 6px;
  margin: 0 -4px;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto;
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text-soft);
  transition: background 0.15s var(--ease), color 0.15s var(--ease), border-color 0.15s var(--ease);
}
.chip:hover { color: var(--primary); border-color: var(--primary-line); }
.chip.is-active {
  background: var(--primary-deep);
  color: var(--header-text);
  border-color: var(--primary-deep);
}

/* ============================================================
   Status banner (error/info)
   ============================================================ */
.status {
  max-width: var(--max-w);
  margin: 8px auto 0;
  padding: 10px 18px;
  font-size: 13px;
  color: var(--danger);
  background: rgba(192, 57, 43, 0.06);
  border-left: 3px solid var(--danger);
}
.status.is-info { color: var(--text-soft); background: var(--primary-soft); border-left-color: var(--primary); }

/* ============================================================
   List
   ============================================================ */
.list {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 14px 18px 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.student {
  background: var(--card);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-md);
  padding: 14px 16px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 12px;
  align-items: center;
  cursor: pointer;
  transition: transform 0.15s var(--ease), box-shadow 0.15s var(--ease), border-color 0.15s var(--ease);
  position: relative;
}
.student:hover {
  border-color: var(--primary-line);
  box-shadow: 0 6px 18px rgba(28, 19, 8, 0.06);
}
.student:active { transform: translateY(1px); }

.s-name {
  font-size: 16.5px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--primary-deep);
}
.s-meta {
  grid-column: 1 / 2;
  font-size: 12.5px;
  color: var(--text-soft);
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  align-items: center;
}
.s-meta .dot {
  width: 3px;
  height: 3px;
  background: var(--border);
  border-radius: 50%;
}
.s-phone {
  font-family: var(--font-mono);
  letter-spacing: 0;
}
.s-course {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--primary);
  background: var(--primary-soft);
  padding: 3px 8px;
  border-radius: 999px;
}

.s-actions {
  grid-row: 1 / 3;
  grid-column: 2 / 3;
  display: flex;
  gap: 6px;
}
.s-actions a {
  width: 38px;
  height: 38px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-soft);
  background: var(--ivory);
  border: 1px solid var(--border-soft);
  text-decoration: none;
  transition: color 0.15s, background 0.15s, border-color 0.15s, transform 0.1s;
}
.s-actions a:hover {
  color: var(--primary-deep);
  border-color: var(--primary-line);
  background: #fff;
}
.s-actions a:active { transform: scale(0.94); }

mark {
  background: rgba(155, 123, 74, 0.18);
  color: inherit;
  padding: 0 2px;
  border-radius: 3px;
}

/* ============================================================
   Skeleton
   ============================================================ */
.skeleton-wrap {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 14px 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.sk-card {
  height: 78px;
  border-radius: var(--r-md);
  background: linear-gradient(90deg,
    var(--ivory) 0%,
    var(--cream) 45%,
    var(--ivory) 90%);
  background-size: 200% 100%;
  animation: shimmer 1.4s linear infinite;
}
@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ============================================================
   Empty
   ============================================================ */
.empty {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 64px 18px;
  text-align: center;
}
.empty-title { font-size: 16px; font-weight: 700; color: var(--text-soft); margin-bottom: 6px; }
.empty-sub { font-size: 13.5px; color: var(--text-mute); }

/* ============================================================
   Footbar
   ============================================================ */
.footbar {
  position: fixed;
  left: 0; right: 0;
  bottom: 0;
  padding: 14px 18px calc(14px + env(safe-area-inset-bottom));
  background: rgba(244, 237, 223, 0.92);
  backdrop-filter: saturate(180%) blur(10px);
  -webkit-backdrop-filter: saturate(180%) blur(10px);
  border-top: 1px solid var(--border-soft);
  font-size: 12px;
  color: var(--text-mute);
  letter-spacing: 0.02em;
  text-align: center;
  z-index: 20;
}
.footbar .dot { margin: 0 6px; opacity: 0.5; }

/* ============================================================
   Detail sheet
   ============================================================ */
.sheet {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(28, 19, 8, 0.42);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  animation: fadeIn 0.2s var(--ease);
}
.sheet-card {
  position: relative;
  width: 100%;
  max-width: var(--max-w);
  max-height: 88vh;
  overflow-y: auto;
  background: var(--card);
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  padding: 26px 22px calc(26px + env(safe-area-inset-bottom));
  box-shadow: 0 -10px 40px rgba(28, 19, 8, 0.18);
  animation: slideUp 0.28s var(--ease);
}
@media (min-width: 720px) {
  .sheet { align-items: center; padding: 24px; }
  .sheet-card { border-radius: var(--r-lg); max-height: 86vh; animation: popIn 0.22s var(--ease); }
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp {
  from { transform: translateY(20px); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}
@keyframes popIn {
  from { transform: scale(0.96); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}

.sheet-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 32px;
  height: 32px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-mute);
  background: var(--ivory);
  border: 1px solid var(--border-soft);
  transition: color 0.15s, background 0.15s;
}
.sheet-close:hover { color: var(--text); background: var(--cream); }

.d-head { margin-bottom: 18px; }
.d-name {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--primary-deep);
  margin-bottom: 6px;
}
.d-sub {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  font-size: 12.5px;
  color: var(--text-soft);
}

.d-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 22px;
}
.d-act {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px;
  border-radius: var(--r-sm);
  background: var(--primary-deep);
  color: var(--header-text);
  font-size: 13.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-decoration: none;
  transition: background 0.15s var(--ease), transform 0.1s;
}
.d-act:hover { background: #2C1F0E; }
.d-act:active { transform: translateY(1px); }
.d-act.is-sub {
  background: var(--ivory);
  color: var(--text);
  border: 1px solid var(--border-soft);
}
.d-act.is-sub:hover { background: var(--cream); }

.d-section {
  border-top: 1px solid var(--border-soft);
  padding-top: 16px;
  margin-bottom: 16px;
}
.d-section-title {
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.22em;
  color: var(--text-mute);
  padding-left: 0.22em;
  text-transform: uppercase;
  margin-bottom: 10px;
}

.d-row {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 10px;
  padding: 8px 0;
  font-size: 13.5px;
}
.d-row dt { color: var(--text-mute); font-weight: 500; }
.d-row dd { color: var(--text); font-weight: 500; letter-spacing: -0.005em; }
.d-row dd a { color: var(--primary); word-break: break-all; }

.d-check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
}
.d-check.is-yes { color: var(--success); }
.d-check.is-no  { color: var(--text-mute); }
.d-check::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.55;
}

/* ============================================================
   Setup (first run)
   ============================================================ */
.setup {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px;
}
.setup-card {
  width: 100%;
  max-width: 460px;
  background: var(--card);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-lg);
  padding: 28px 26px;
  box-shadow: 0 16px 40px rgba(28, 19, 8, 0.1);
}
.setup-card h2 {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--primary-deep);
  margin-bottom: 8px;
}
.setup-desc {
  font-size: 13.5px;
  color: var(--text-soft);
  margin-bottom: 18px;
  line-height: 1.6;
}
.setup-card input {
  width: 100%;
  padding: 12px 14px;
  font-size: 13.5px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--card);
  margin-bottom: 10px;
  font-family: var(--font-mono);
}
.setup-card input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(155, 123, 74, 0.14);
}
.setup-err {
  font-size: 12px;
  color: var(--danger);
  margin-bottom: 10px;
}
.setup-card button {
  width: 100%;
  padding: 13px;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.04em;
  background: var(--primary-deep);
  color: var(--header-text);
  border-radius: var(--r-sm);
  transition: background 0.15s var(--ease), transform 0.1s var(--ease);
}
.setup-card button:hover { background: #2C1F0E; }
.setup-card button:active { transform: translateY(1px); background: #3A2A14; }
.setup-err {
  font-size: 13px;
  color: var(--danger);
  margin-bottom: 10px;
  padding: 8px 12px;
  background: rgba(192, 57, 43, 0.08);
  border-left: 3px solid var(--danger);
  border-radius: 4px;
  line-height: 1.5;
}
.setup-hint {
  margin-top: 12px;
  font-size: 11.5px;
  color: var(--text-mute);
  text-align: center;
}

/* ============================================================
   Responsive (PC adjustments)
   ============================================================ */
@media (min-width: 720px) {
  body { font-size: 16px; }
  .student { padding: 16px 18px; }
  .s-name { font-size: 17.5px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
