:root {
  --bg: #f4f6f8; --card: #fff; --text: #17202a; --muted: #6b7684; --line: #e3e7ec;
  --accent: #0f766e; --accent-soft: #ccfbf1; --danger: #b91c1c; --danger-soft: #fee2e2; --ok: #15803d; --ok-soft: #dcfce7;
  --btn-text: #fff; --shadow: 0 8px 30px rgba(20, 24, 40, .12);
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0f1418; --card: #171d23; --text: #e8edf2; --muted: #8a96a3; --line: #263039; --accent: #2dd4bf; --accent-soft: #10302d; --danger: #f87171; --danger-soft: #3b1515; --ok: #4ade80; --ok-soft: #14351f; --btn-text: #0f1418; --shadow: 0 8px 30px rgba(0,0,0,.5); }
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: -apple-system, "Pretendard", "Apple SD Gothic Neo", "Noto Sans KR", "Roboto", sans-serif; line-height: 1.5; }
a { color: var(--accent); text-decoration: none; }
button { font: inherit; }
.muted { color: var(--muted); } .small { font-size: 12px; } .grow { flex: 1; }

/* login */
.login { max-width: 360px; margin: 70px auto 0; padding: 0 16px; text-align: center; }
.login h1 { font-size: 26px; margin: 0 0 4px; }
.box { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 18px; margin-top: 18px; text-align: left; }
input[type=password], input[type=text], .input { font: inherit; width: 100%; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg); color: var(--text); }
input:focus, .input:focus { outline: 2px solid var(--accent); border-color: transparent; }
.btn { font: inherit; font-weight: 700; padding: 11px 16px; border-radius: 12px; border: 0; background: var(--accent); color: var(--btn-text); cursor: pointer; text-decoration: none; display: inline-block; }
.btn.block { display: block; width: 100%; margin-top: 12px; }
.btn.small { padding: 7px 12px; font-size: 13px; }
.btn.secondary { background: var(--line); color: var(--text); }
.btn.danger { background: var(--danger-soft); color: var(--danger); }
.btn:disabled { opacity: .5; cursor: default; }
.flash { padding: 12px 14px; border-radius: 12px; margin-bottom: 12px; font-size: 14px; }
.flash.err { background: var(--danger-soft); color: var(--danger); }

/* shell with tabs */
body.shell { display: flex; flex-direction: column; overflow: hidden; }
.bar { display: flex; align-items: center; gap: 12px; padding: 8px 12px; padding-top: max(8px, env(safe-area-inset-top)); background: var(--card); border-bottom: 1px solid var(--line); flex: none; }
.bar .brand { font-weight: 800; }
.tabs { display: flex; gap: 2px; background: var(--line); padding: 3px; border-radius: 999px; }
.tabs a { padding: 6px 14px; border-radius: 999px; color: var(--muted); font-size: 14px; font-weight: 600; }
.tabs a.on { background: var(--card); color: var(--text); }
.tbtn { display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); color: var(--text); cursor: pointer; font-size: 13px; font-weight: 600; text-decoration: none; }
.tbtn.primary { background: var(--accent); border-color: var(--accent); color: var(--btn-text); }
.tbtn.danger { color: var(--danger); }
.tbtn:disabled { opacity: .45; }
.frames { flex: 1; min-height: 0; position: relative; }
.frames iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: #0f1418; }
.frames iframe.hidden { visibility: hidden; }
#f-files { background: var(--bg); }

/* file manager */
body.fm { display: flex; flex-direction: column; }
.fmbar { display: flex; gap: 8px; align-items: center; padding: 8px 10px; background: var(--card); border-bottom: 1px solid var(--line); flex-wrap: wrap; flex: none; }
.quick { display: flex; gap: 4px; }
.quick button { height: 32px; padding: 0 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg); color: var(--text); cursor: pointer; font-size: 13px; }
.pathform { flex: 1; min-width: 200px; }
.pathform input { padding: 7px 10px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }
.actions { display: flex; gap: 6px; }
.list { flex: 1; overflow: auto; padding: 4px 6px 120px; }
.row { display: grid; grid-template-columns: 34px 1fr 80px 130px 110px 34px; align-items: center; gap: 6px; padding: 8px 6px; border-radius: 10px; font-size: 14px; cursor: pointer; }
.row.head { color: var(--muted); font-size: 12px; cursor: default; border-bottom: 1px solid var(--line); border-radius: 0; margin-bottom: 4px; }
.row:not(.head):hover { background: var(--card); }
.row.sel { background: var(--accent-soft); }
.row.dim { opacity: .5; }
.row .ic { text-align: center; font-size: 16px; }
.row .chk { font-size: 18px; }
.row .name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }
.row.dir .name { font-weight: 600; }
.c-size { text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; font-size: 12px; }
.c-time, .c-own { color: var(--muted); font-size: 12px; white-space: nowrap; }
.row .dots { border: 0; background: none; color: var(--muted); font-size: 18px; cursor: pointer; border-radius: 8px; }
.row .dots:hover { background: var(--line); color: var(--text); }
@media (max-width: 640px) { .row { grid-template-columns: 30px 1fr 70px 34px; } .c-time, .c-own, .row.head .c-time, .row.head .c-own { display: none; } }
.note { color: var(--muted); font-size: 13px; padding: 10px 8px; }
.drop { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; background: rgba(15, 118, 110, .16); border: 3px dashed var(--accent); font-size: 18px; font-weight: 700; color: var(--accent); pointer-events: none; }
.drop[hidden] { display: none; }
.selbar, .uploads { position: fixed; left: 50%; transform: translateX(-50%); bottom: max(12px, env(safe-area-inset-bottom)); width: min(680px, calc(100% - 20px)); background: var(--card); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); z-index: 6; }
.selbar { display: flex; gap: 6px; align-items: center; padding: 8px 10px; }
.selbar .cnt { flex: 1; font-weight: 700; font-size: 14px; }
.uploads { padding: 8px 12px; max-height: 40vh; overflow: auto; }
.uhead { display: flex; justify-content: space-between; font-weight: 700; font-size: 14px; margin-bottom: 4px; }
.xbtn { border: 0; background: var(--line); color: var(--text); border-radius: 50%; width: 26px; height: 26px; cursor: pointer; }
.urow { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; padding: 5px 0; border-top: 1px solid var(--line); font-size: 13px; }
.uname { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ust { color: var(--muted); } .urow.done .ust { color: var(--ok); } .urow.error .ust { color: var(--danger); }
.ubar { grid-column: 1 / -1; height: 4px; background: var(--line); border-radius: 999px; overflow: hidden; } .ufill { height: 100%; background: var(--accent); } .urow.done .ufill { background: var(--ok); }

/* overlays */
.overlay { position: fixed; inset: 0; z-index: 30; background: rgba(10, 12, 20, .45); display: grid; place-items: center; }
.overlay.dark { background: rgba(0,0,0,.95); }
.overlay.sheet { place-items: end center; }
.overlay.editor { place-items: stretch; background: var(--bg); }
.overlay[hidden] { display: none; }
.dialog { width: min(440px, calc(100% - 28px)); background: var(--card); border-radius: 16px; padding: 18px; box-shadow: var(--shadow); }
.dialog h3 { margin: 0 0 12px; font-size: 16px; word-break: break-all; }
.dbtns { display: flex; gap: 8px; justify-content: flex-end; margin-top: 14px; }
.menu { width: min(480px, 100%); background: var(--card); border-radius: 16px 16px 0 0; padding: 8px 8px max(10px, env(safe-area-inset-bottom)); box-shadow: var(--shadow); }
@media (min-width: 600px) { .overlay.sheet { place-items: center; } .menu { border-radius: 16px; } }
.mitem { display: block; width: 100%; text-align: left; padding: 13px 14px; border: 0; background: none; color: var(--text); font-size: 15px; border-radius: 10px; cursor: pointer; }
.mitem:hover { background: var(--bg); } .mitem.danger { color: var(--danger); }
.edwrap { display: flex; flex-direction: column; width: 100%; height: 100%; }
.edbar { display: flex; align-items: center; gap: 10px; padding: 8px 12px; background: var(--card); border-bottom: 1px solid var(--line); }
.edbar.dark { background: #111; color: #eee; border: 0; }
.edname { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
textarea.edit { flex: 1; width: 100%; border: 0; resize: none; padding: 14px 16px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13.5px; line-height: 1.5; background: var(--card); color: var(--text); outline: none; tab-size: 4; white-space: pre; overflow-wrap: normal; overflow-x: auto; }
.viewer { display: flex; flex-direction: column; width: 100%; height: 100%; }
.vstage { flex: 1; display: grid; place-items: center; min-height: 0; padding: 10px; }
.vstage img { max-width: 100%; max-height: 100%; object-fit: contain; }
.toast { position: fixed; left: 50%; bottom: max(80px, calc(env(safe-area-inset-bottom) + 80px)); transform: translate(-50%, 20px); background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 999px; font-size: 14px; opacity: 0; transition: .2s; z-index: 40; pointer-events: none; max-width: calc(100% - 40px); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err { background: var(--danger); color: #fff; }
