*,*::before,*::after{box-sizing:border-box;}
:root{
  --bg:#FFFFFF; --surface:#FFFFFF; --surface-2:#F2F5F3; --ink:#262E2B; --ink-muted:#63706A;
  --border:#DFE5E1; --accent:#0F5C42; --accent-ink:#FFFFFF; --accent-soft:#E1EFE8;
  --accent-2:#111111; --accent-2-soft:#EBEBEB; --danger:#D31F2A; --danger-soft:#FBE1E2;
  --danger-ink:#7C1015; --focus:#0F5C42; --shadow:0 1px 2px rgba(20,30,27,.06),0 8px 24px -12px rgba(20,30,27,.18);
}
:root[data-theme="dark"]{
  --bg:#0B0F0D; --surface:#131815; --surface-2:#1A2019; --ink:#EBF1EE; --ink-muted:#8FA098;
  --border:#293029; --accent:#3FBF98; --accent-ink:#08130F; --accent-soft:#172B24;
  --accent-2:#F2F2F2; --accent-2-soft:#252525; --danger:#FF6A6F; --danger-soft:#3A1A1B;
  --danger-ink:#FFDBDC; --focus:#3FBF98; --shadow:0 1px 2px rgba(0,0,0,.4),0 8px 24px -12px rgba(0,0,0,.6);
}
html,body{background:var(--bg);transition:background-color .15s;}
body{margin:0;color:var(--ink);font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Apple SD Gothic Neo","Malgun Gothic","Noto Sans KR",sans-serif;
  font-size:15px;line-height:1.6;-webkit-font-smoothing:antialiased;min-height:100vh;-webkit-tap-highlight-color:transparent;}
.mono,.tabular{font-family:ui-monospace,"SFMono-Regular",Menlo,Consolas,"Liberation Mono",monospace;font-variant-numeric:tabular-nums;}
h1,h2,h3{text-wrap:balance;font-weight:600;margin:0;}
a{color:var(--accent);}
button{font-family:inherit;}
.boot-loading{padding:48px;text-align:center;color:var(--ink-muted);}

/* brand */
.brand-row{display:flex;justify-content:center;margin-bottom:18px;}
.brand-row.left{justify-content:flex-start;}
.brand-logo{height:44px;width:auto;display:block;}

/* theme toggle */
.theme-toggle{position:fixed;bottom:14px;right:14px;z-index:40;display:flex;align-items:center;gap:8px;
  background:var(--surface);border:1px solid var(--border);border-radius:999px;padding:6px 8px 6px 12px;
  box-shadow:0 2px 8px -2px rgba(20,30,27,.18);}
.theme-toggle-label{display:flex;align-items:center;gap:6px;font-size:12px;font-weight:600;color:var(--ink-muted);white-space:nowrap;}
.theme-toggle-label svg{width:15px;height:15px;flex:none;}
.theme-toggle-btns{display:flex;background:var(--surface-2);border-radius:999px;padding:3px;gap:2px;}
.theme-btn{display:flex;align-items:center;justify-content:center;width:26px;height:26px;border:0;border-radius:999px;
  background:transparent;cursor:pointer;color:var(--ink-muted);padding:0;}
.theme-btn svg{width:15px;height:15px;pointer-events:none;}
.theme-btn.active{background:var(--accent);color:var(--accent-ink);}
@media (max-width:480px){
  .theme-toggle{bottom:10px;right:10px;padding:5px 6px 5px 12px;}
  .theme-toggle-label .label-text{font-size:11px;}
}

/* layout shells */
.survey-shell{max-width:640px;margin:0 auto;padding:40px 20px 64px;}
.admin-shell{max-width:980px;margin:0 auto;padding:28px 20px 64px;}
@media (max-width:640px){.survey-shell{padding:24px 16px 48px;} .admin-shell{padding:20px 14px 48px;}}
@media (max-width:480px){
  .page-title{font-size:23px;}
  .brand-logo{height:38px;}
  .section-title{font-size:15px;}
}

/* cards */
.card{background:var(--surface);border:1px solid var(--border);border-radius:6px;box-shadow:none;}
.card-pad{padding:28px;}
@media (max-width:640px){.card-pad{padding:20px;}}
.section-gap{display:flex;flex-direction:column;gap:20px;}
.divider{height:2px;background:var(--ink);opacity:.1;border:0;margin:0;}

/* eyebrow / badges */
.eyebrow{font-family:ui-monospace,"SFMono-Regular",Menlo,Consolas,"Liberation Mono",monospace;font-size:11px;letter-spacing:.09em;text-transform:uppercase;color:var(--ink-muted);}
.badge{display:inline-flex;align-items:center;gap:6px;padding:4px 10px;border-radius:999px;font-size:12px;font-weight:600;}
.badge-dot{width:6px;height:6px;border-radius:50%;background:currentColor;}
.badge-draft{background:var(--surface-2);color:var(--ink-muted);}
.badge-before{background:var(--accent-2-soft);color:var(--accent-2);}
.badge-open{background:var(--accent-soft);color:var(--accent);}
.badge-closed{background:var(--surface-2);color:var(--ink-muted);}

/* typography */
.page-title{font-size:28px;letter-spacing:-.01em;padding-bottom:14px;border-bottom:3px solid var(--accent);}
.section-title{font-size:16px;font-weight:600;}
.muted{color:var(--ink-muted);}
.small{font-size:13px;}

/* forms */
label.field-label{display:block;font-size:13px;font-weight:600;margin-bottom:6px;color:var(--ink);}
.field-hint{font-size:12px;color:var(--ink-muted);margin-top:4px;}
input[type=text],input[type=password],input[type=number],input[type=datetime-local],textarea{
  width:100%;padding:12px 14px;border:1px solid var(--border);border-radius:6px;background:var(--surface);
  color:var(--ink);font-size:16px;font-family:inherit;}
input[type=number]{font-family:ui-monospace,"SFMono-Regular",Menlo,Consolas,"Liberation Mono",monospace;}
textarea{resize:vertical;min-height:84px;}
input:focus-visible,textarea:focus-visible,button:focus-visible,a:focus-visible{
  outline:2px solid var(--focus);outline-offset:2px;}
.field-row{display:grid;grid-template-columns:1fr 1fr;gap:14px;}
@media (max-width:520px){.field-row{grid-template-columns:1fr;}}
.field{margin-bottom:16px;}

/* choice option custom radio */
.choice-list{display:flex;flex-direction:column;gap:8px;margin-top:8px;}
.choice-option{display:flex;align-items:center;gap:12px;padding:13px 15px;border:1px solid var(--border);
  border-radius:6px;cursor:pointer;transition:border-color .15s,background .15s,border-width .15s;min-height:44px;}
.choice-option:hover{border-color:var(--accent);}
.choice-option input{accent-color:var(--accent);width:19px;height:19px;flex:none;}
.choice-option.checked{border-color:var(--accent);border-width:2px;padding:12px 14px;background:var(--accent-soft);}
.question-block{padding:20px 0;}
.question-block + .question-block{border-top:1px solid var(--border);}
.question-num{color:var(--accent);font-family:ui-monospace,"SFMono-Regular",Menlo,Consolas,"Liberation Mono",monospace;font-size:13px;margin-right:6px;}
.required-mark{color:var(--danger);margin-left:2px;}
.error-text{color:var(--danger);font-size:12px;margin-top:6px;}
.question-block.invalid{background:var(--danger-soft);border-radius:6px;padding-left:14px;padding-right:14px;margin:0 -14px;}

/* buttons */
.btn{display:inline-flex;align-items:center;justify-content:center;gap:8px;padding:10px 18px;border-radius:6px;
  font-size:14px;font-weight:600;border:1px solid transparent;cursor:pointer;transition:opacity .15s,background .15s;
  min-height:44px;}
.btn:disabled{opacity:.5;cursor:not-allowed;}
.btn-primary{background:var(--accent);color:var(--accent-ink);}
.btn-primary:hover:not(:disabled){opacity:.9;}
.btn-ghost{background:transparent;color:var(--ink);border-color:var(--border);}
.btn-ghost:hover:not(:disabled){border-color:var(--accent);color:var(--accent);}
.btn-danger{background:transparent;color:var(--danger);border-color:var(--danger-soft);}
.btn-danger:hover:not(:disabled){background:var(--danger-soft);}
.btn-sm{padding:7px 12px;font-size:13px;border-radius:6px;min-height:auto;}
.btn-block{width:100%;}

/* admin top bar */
.admin-top{display:flex;flex-wrap:wrap;align-items:center;justify-content:space-between;gap:12px;margin-bottom:22px;}
.admin-top.shell-header{padding-bottom:18px;border-bottom:3px solid var(--ink);}
.admin-title-row{display:flex;align-items:center;gap:10px;flex-wrap:wrap;}
.tabs{display:flex;gap:4px;background:var(--surface-2);padding:4px;border-radius:6px;border:1px solid var(--border);}
.tab-btn{padding:8px 16px;border-radius:5px;border:0;background:transparent;color:var(--ink-muted);font-weight:600;font-size:13px;cursor:pointer;}
.tab-btn.active{background:var(--surface);color:var(--ink);box-shadow:none;border:1px solid var(--ink);}

.print-only{display:none;}
.bubble-cloud{display:none;}

/* stat tiles */
.stat-grid{display:grid;grid-template-columns:repeat(4,1fr);gap:12px;}
@media (max-width:640px){.stat-grid{grid-template-columns:1fr 1fr;}}
.stat-tile{padding:16px;border:1px solid var(--border);border-radius:6px;background:var(--surface-2);}
.stat-value{font-family:ui-monospace,"SFMono-Regular",Menlo,Consolas,"Liberation Mono",monospace;font-size:24px;font-weight:600;}
.stat-label{font-size:12px;color:var(--ink-muted);margin-top:2px;}

/* bar chart */
.bar-row{display:grid;grid-template-columns:1fr auto;gap:10px;align-items:center;padding:6px 0;}
.bar-label{font-size:13px;}
.bar-track{grid-column:1/-1;height:8px;border-radius:5px;background:var(--surface-2);overflow:hidden;margin-bottom:2px;}
.bar-fill{height:100%;background:var(--accent);border-radius:5px;}
.bar-count{font-family:ui-monospace,"SFMono-Regular",Menlo,Consolas,"Liberation Mono",monospace;font-size:12px;color:var(--ink-muted);white-space:nowrap;}
.q-result-card{padding:18px 0;}
.q-result-card + .q-result-card{border-top:1px solid var(--border);}

/* text answer list */
.answer-list{display:flex;flex-direction:column;gap:8px;max-height:280px;overflow-y:auto;margin-top:10px;padding-right:4px;}
.answer-item{padding:10px 12px;background:var(--surface-2);border-radius:6px;font-size:13px;}
.answer-item time{display:block;color:var(--ink-muted);font-size:11px;margin-top:4px;font-family:ui-monospace,"SFMono-Regular",Menlo,Consolas,"Liberation Mono",monospace;}
.empty-note{color:var(--ink-muted);font-size:13px;padding:8px 0;}

/* table */
.table-scroll{overflow-x:auto;border:1px solid var(--border);border-radius:6px;}
table{border-collapse:collapse;width:100%;min-width:520px;font-size:13px;}
th,td{padding:9px 12px;text-align:left;border-bottom:1px solid var(--border);white-space:nowrap;max-width:220px;overflow:hidden;text-overflow:ellipsis;}
thead th{background:var(--surface-2);font-size:11px;text-transform:uppercase;letter-spacing:.06em;color:var(--ink-muted);position:sticky;top:0;}
tbody tr:last-child td{border-bottom:0;}
td.mono{font-family:ui-monospace,"SFMono-Regular",Menlo,Consolas,"Liberation Mono",monospace;}

/* link box */
.link-row{display:flex;gap:8px;align-items:center;}
.link-row input{font-family:ui-monospace,"SFMono-Regular",Menlo,Consolas,"Liberation Mono",monospace;font-size:12px;color:var(--ink-muted);background:var(--surface-2);}

/* flash / toast */
.flash{padding:12px 16px;border-radius:6px;background:var(--accent-soft);color:var(--accent);font-size:13px;margin-bottom:18px;border-left:3px solid var(--accent);}
.flash-warn{background:var(--accent-2-soft);color:var(--accent-2);}
.flash-error{background:var(--danger-soft);color:var(--danger-ink);}

/* passcode gate */
.gate-shell{max-width:360px;margin:80px auto;text-align:center;}

/* footer link */
.foot-link{text-align:center;margin-top:28px;font-size:13px;}

/* modal */
.modal-backdrop{position:fixed;inset:0;background:rgba(15,20,19,.5);display:flex;align-items:center;justify-content:center;padding:20px;z-index:50;}
.modal-card{max-width:380px;width:100%;}
.response-detail-card{max-width:560px;max-height:85vh;display:flex;flex-direction:column;}
.response-detail-body{overflow-y:auto;margin:4px -4px 14px;padding:0 4px;}
.response-answer-text{margin:0;font-size:14px;line-height:1.6;white-space:pre-wrap;word-break:break-word;}
@media (prefers-reduced-motion: reduce){*{transition:none !important;animation:none !important;}}

/* print */
@page{size:A4;margin:14mm;}
@media print{
  html,body{background:#fff;}
  :root,:root[data-theme="dark"]{--bg:#fff;--surface:#fff;--surface-2:#F2F5F3;--ink:#1A1A1A;--ink-muted:#555;--border:#CCC;}
  *{-webkit-print-color-adjust:exact !important;print-color-adjust:exact !important;color-adjust:exact !important;}
  .theme-toggle,.modal-backdrop,.tabs,.foot-link,#back-list,.survey-row-actions,.btn,input,#draw-stage{display:none !important;}
  .admin-shell{max-width:100%;padding:0;padding-bottom:16mm;}
  .print-footer{position:fixed;bottom:6mm;left:0;right:0;margin:0 !important;font-size:10px;color:#555;text-align:center;}
  .print-top-row{display:flex !important;gap:16px;align-items:stretch;margin-bottom:16px;}
  .print-top-row .card{flex:1;margin-bottom:0 !important;}
  .print-stat-col{flex:none;width:170px;display:flex;flex-direction:column;gap:12px;}
  .print-stat-box{background:#4A4F55;border-radius:8px;padding:18px;display:flex;flex-direction:column;justify-content:center;break-inside:avoid;}
  .print-stat-value{font-size:34px;font-weight:800;color:#fff;line-height:1;}
  .print-stat-label{font-size:12px;color:#fff;opacity:.9;margin-top:6px;}
  .print-period-box{background:#F2F5F3;border:1px solid #ccc;border-radius:8px;padding:14px;break-inside:avoid;}
  .print-period-label{font-size:11px;color:#555;margin-bottom:6px;}
  .print-period-value{font-size:12px;color:#1A1A1A;font-weight:600;line-height:1.5;}
  .card{border:1px solid #ccc;box-shadow:none;}
  .no-print{display:none !important;}
  .print-only{display:block !important;}
  .answer-list{max-height:none;overflow:visible;}
  .table-scroll{overflow:visible;border:none;}
  table{width:100%;font-size:11px;}
  .q-result-card,.stat-tile{break-inside:avoid;}
  .page-title,.section-title,h1,h2{break-after:avoid;}
  .daily-bars{overflow-x:visible !important;flex-wrap:wrap;row-gap:14px;height:auto !important;}
  .daily-bar-item{height:120px;}
  .daily-chart-row{break-inside:avoid;flex-direction:column !important;}
  .daily-side-col{width:auto !important;border-left:0 !important;border-top:1px solid var(--border);padding-left:0 !important;padding-top:8px;margin-top:8px;}
  .daily-period-line{font-size:11px;color:#555;white-space:nowrap;}
  .bubble-cloud{display:flex !important;flex-wrap:wrap;gap:10px;margin-top:6px;}
  .bubble-item{position:relative;padding:9px 16px;border-radius:16px;font-size:12px;font-weight:500;line-height:1.5;max-width:230px;word-break:break-word;box-shadow:0 1px 2px rgba(0,0,0,.15);break-inside:avoid;color:#000 !important;}
  .bubble-item::after{content:'';position:absolute;left:18px;bottom:-5px;width:11px;height:11px;background:inherit;border-radius:0 0 2px 0;transform:rotate(45deg);}
  .bubble-c0{background:#FF6B6B;}
  .bubble-c1{background:#4DABF7;}
  .bubble-c2{background:#69DB7C;}
  .bubble-c3{background:#FFA94D;}
  .bubble-c4{background:#DA77F2;}
  .bubble-c5{background:#FFD43B;}
}
