/* ============ Design tokens ============ */
:root {
  --sidebar-w: 248px;
  --topbar-h: 64px;
  --bg: #f3f5f9;
  --panel: #ffffff;
  --panel-2: #f8fafc;
  --text: #172033;
  --muted: #68758c;
  --faint: #93a0b4;
  --line: #e3e8f0;
  --line-strong: #d3dbe7;
  --accent: #2563eb;
  --accent-2: #1d4ed8;
  --accent-weak: #eaf1ff;
  --teal: #0f766e;
  --danger: #d14343;
  --danger-weak: #fdecec;
  --warn: #b45309;
  --warn-weak: #fff7e6;
  --ok: #15803d;
  --ok-weak: #eaf7ee;
  --sidebar: #0d1728;
  --sidebar-2: #111f35;
  --sidebar-text: #e7edf7;
  --sidebar-muted: #8fa0bb;
  --radius: 12px;
  --radius-sm: 9px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 10px 30px rgba(16, 24, 40, .07);
  --shadow-lg: 0 24px 70px rgba(9, 18, 36, .28);
  --sans: "Pretendard", "Malgun Gothic", "맑은 고딕", "Segoe UI", system-ui, -apple-system, sans-serif;
  --mono: "Cascadia Mono", "Consolas", monospace;
}

[data-theme="dark"] {
  --bg: #0b1220;
  --panel: #111b2c;
  --panel-2: #0e1828;
  --text: #e6ecf7;
  --muted: #9aa9c0;
  --faint: #7183a0;
  --line: #223049;
  --line-strong: #2d3d59;
  --accent: #5b8cff;
  --accent-2: #7aa2ff;
  --accent-weak: #18294b;
  --danger: #f07b7b;
  --danger-weak: #3a1c22;
  --warn: #f0b35b;
  --warn-weak: #3a2a13;
  --ok: #65cf8a;
  --ok-weak: #163124;
  --sidebar: #080f1c;
  --sidebar-2: #0c1627;
  --sidebar-text: #e6ecf7;
  --sidebar-muted: #8194b2;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 12px 36px rgba(0, 0, 0, .26);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); text-decoration: none; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.mono { font-family: var(--mono); }
.nowrap { white-space: nowrap; }
.spacer { flex: 1; }

/* ============ Buttons / fields ============ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 36px;
  padding: 0 13px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--panel);
  color: var(--text);
  font-weight: 600;
  font-size: 13px;
  white-space: nowrap;
  transition: .15s ease;
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-2); border-color: var(--accent-2); color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--panel-2); color: var(--text); }
.btn.danger { color: var(--danger); border-color: var(--line-strong); }
.btn.danger:hover { background: var(--danger-weak); border-color: var(--danger); }
.btn.sm { height: 30px; padding: 0 10px; font-size: 12.5px; border-radius: 8px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.icon-btn {
  width: 34px;
  height: 34px;
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  color: inherit;
  font-size: 16px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.icon-btn:hover { background: rgba(255, 255, 255, .08); }
.main .icon-btn:hover { background: var(--panel-2); }

.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: 12.5px; font-weight: 700; color: var(--muted); }
.field input, .field select, .field textarea,
.input, .select, .textarea {
  height: 38px;
  padding: 0 11px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--panel);
  color: var(--text);
  outline: none;
  transition: .15s ease;
}
.field textarea, .textarea { height: auto; padding: 10px 11px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus,
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 14%, transparent);
}
.check { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); font-size: 13px; cursor: pointer; }
.check input { accent-color: var(--accent); width: 15px; height: 15px; }
.form-msg { min-height: 18px; font-size: 12.5px; color: var(--danger); }
.form-msg.ok { color: var(--ok); }

.badge {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--accent-weak);
  color: var(--accent);
  font-size: 11.5px;
  font-weight: 700;
}
.badge.gray { background: var(--panel-2); color: var(--muted); border: 1px solid var(--line); }
.badge.warn { background: var(--warn-weak); color: var(--warn); }
.badge.danger { background: var(--danger-weak); color: var(--danger); }
.badge.ok { background: var(--ok-weak); color: var(--ok); }

.tag {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 8px;
  border-radius: 6px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 11.5px;
}

/* ============ Login ============ */
.login-screen {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.15fr .85fr;
  background: var(--panel);
}
.login-art {
  position: relative;
  overflow: hidden;
  background: #101827;
  background-image: repeating-linear-gradient(to bottom, transparent 0 39px, rgba(255, 255, 255, .05) 39px 40px);
  color: #fff;
  display: flex;
  align-items: center;
  padding: 72px 8vw;
}
.login-grid { display: none; }
.login-orbit { display: none; }
.login-copy { position: relative; max-width: 620px; }
.login-copy h1 { margin: 18px 0 8px; font-size: clamp(38px, 3.4vw, 58px); letter-spacing: -2px; line-height: 1.08; }
.login-copy p { margin: 0 0 36px; color: #a9bcd8; font-size: 17px; }
.login-copy ul { margin: 0; padding: 0; list-style: none; display: grid; gap: 12px; color: #c7d5ea; font-size: 14px; }
.login-copy li { display: flex; align-items: center; gap: 10px; }
.login-copy li::before { content: ""; width: 5px; height: 5px; border-radius: 1px; background: #6b8fc4; }
.login-panel { display: flex; align-items: center; justify-content: center; padding: 48px; background: var(--panel); }
.login-card { width: 100%; max-width: 404px; display: grid; gap: 18px; }
.login-brand { display: flex; align-items: center; gap: 13px; margin-bottom: 10px; }
.login-brand strong { display: block; font-size: 19px; letter-spacing: -.4px; }
.login-brand span { display: block; color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.login-options { display: flex; justify-content: space-between; align-items: center; margin-top: -4px; }
.login-foot { display: flex; justify-content: space-between; color: var(--faint); font-size: 11.5px; padding-top: 6px; border-top: 1px solid var(--line); }
.brand-mark {
  width: 42px; height: 42px; border-radius: 12px;
  display: inline-flex; align-items: center; justify-content: center;
  background: linear-gradient(145deg, #3b82f6, #1d4ed8);
  color: #fff; font-weight: 800; font-size: 13px; letter-spacing: -.3px;
  box-shadow: 0 6px 16px rgba(37, 99, 235, .3);
  flex: none;
}
.brand-mark.large { width: 58px; height: 58px; border-radius: 16px; font-size: 15px; }

/* ============ App shell ============ */
.app { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); height: 100vh; }
.sidebar {
  background: var(--sidebar);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-right: 1px solid rgba(255,255,255,.04);
}
.sidebar-brand { display: flex; align-items: center; gap: 12px; padding: 22px 20px 18px; }
.sidebar-brand .brand-mark { width: 38px; height: 38px; border-radius: 11px; font-size: 12px; }
.sidebar-brand-text { min-width: 0; }
.sidebar-brand-text strong { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font-size: 12.5px; line-height: 1.3; color: var(--sidebar-text); }
.sidebar-brand-text span { display: block; color: var(--sidebar-muted); font-size: 11px; margin-top: 2px; }
.nav { display: flex; flex-direction: column; gap: 2px; padding: 8px 12px; overflow: auto; }
.nav-item {
  display: flex; align-items: center; gap: 11px;
  height: 40px; padding: 0 12px;
  border: 0; border-radius: 9px;
  background: transparent; color: var(--sidebar-muted);
  font-size: 13.5px; font-weight: 600; text-align: left;
  transition: .14s ease;
}
.nav-item svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.nav-item:hover { background: rgba(255,255,255,.055); color: var(--sidebar-text); }
.nav-item.active { background: linear-gradient(90deg, rgba(59,130,246,.22), rgba(59,130,246,.08)); color: #fff; box-shadow: inset 3px 0 0 #5b8cff; }
.nav-item .soon { margin-left: auto; font-style: normal; font-size: 9.5px; font-weight: 700; color: #7f92ad; border: 1px solid rgba(255,255,255,.13); border-radius: 4px; padding: 1px 4px; }
.nav-sep { height: 1px; background: rgba(255,255,255,.07); margin: 10px 12px; }
.sidebar-foot { margin-top: auto; padding: 14px 14px 18px; border-top: 1px solid rgba(255,255,255,.06); }
.me-card { display: flex; align-items: center; gap: 10px; padding: 9px 8px; border-radius: 10px; }
.me-card:hover { background: rgba(255,255,255,.045); }
.avatar { width: 34px; height: 34px; border-radius: 50%; display: flex; align-items: center; justify-content: center; background: linear-gradient(145deg, #334e77, #22344f); color: #dbe7fb; font-weight: 800; font-size: 13px; flex: none; }
.me-text { min-width: 0; }
.me-text strong { display: block; font-size: 12.5px; color: var(--sidebar-text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me-text span { display: block; font-size: 11px; color: var(--sidebar-muted); margin-top: 1px; }
.sidebar-actions { display: flex; justify-content: flex-end; gap: 2px; margin-top: 4px; }
.sidebar-actions .icon-btn { color: var(--sidebar-muted); width: 30px; height: 30px; }

.main { min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.topbar {
  height: var(--topbar-h);
  flex: none;
  display: flex;
  align-items: center;
  gap: 22px;
  padding: 0 28px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.topbar-title { min-width: 220px; }
.crumb { font-size: 16px; font-weight: 800; letter-spacing: -.3px; }
.crumb-sub { font-size: 11.5px; color: var(--muted); margin-top: 1px; }
.topbar-search { position: relative; flex: 1; max-width: 460px; margin-left: 8px; }
.topbar-search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; fill: none; stroke: var(--faint); stroke-width: 1.8; }
.topbar-search input {
  width: 100%; height: 38px; padding: 0 12px 0 36px;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--panel-2); color: var(--text); outline: none;
}
.topbar-search input:focus { border-color: var(--accent); background: var(--panel); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 12%, transparent); }
.topbar-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.view { flex: 1; min-height: 0; overflow: auto; padding: 26px 30px 40px; }
.view.flush { padding: 0; overflow: hidden; }

/* ============ Common page ============ */
.page-head { display: flex; align-items: flex-end; gap: 18px; margin-bottom: 22px; }
.page-head h2 { margin: 0; font-size: 22px; letter-spacing: -.5px; }
.page-head p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.page-actions { margin-left: auto; display: flex; gap: 8px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.panel-head { display: flex; align-items: center; gap: 12px; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.panel-head h3 { margin: 0; font-size: 14px; }
.panel-head .muted { font-size: 12px; }
.panel-body { padding: 18px; }
.empty { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; min-height: 180px; color: var(--faint); text-align: center; font-size: 13px; }
.empty strong { color: var(--muted); font-size: 14px; }

/* ============ Dashboard ============ */
.dash { max-width: 1680px; margin: 0 auto; }
.dash-hero {
  display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 18px; margin-bottom: 18px;
}
.hero-card {
  position: relative; overflow: hidden;
  padding: 28px 30px;
  border-radius: 14px;
  background-color: var(--panel);
  background-image: repeating-linear-gradient(to bottom, transparent 0 27px, var(--line) 27px 28px);
  border: 1px solid var(--line);
  color: var(--text);
}
.hero-card::after { content: ""; position: absolute; right: 0; top: 0; bottom: 0; width: 3px; background: var(--accent); opacity: .5; }
.hero-eyebrow { font-size: 12px; color: var(--muted); }
.hero-card h2 { margin: 8px 0 6px; font-size: 26px; letter-spacing: -.4px; font-weight: 600; }
.hero-card p { margin: 0; color: var(--muted); font-size: 13px; }
.hero-quick { display: flex; gap: 8px; margin-top: 24px; flex-wrap: wrap; }
.quick-card { padding: 20px; display: flex; flex-direction: column; gap: 8px; }
.quick-card h3 { margin: 0 0 4px; font-size: 14px; }
.quick-row { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); color: var(--text); text-align: left; }
.quick-row:hover { border-color: var(--line-strong, var(--line)); background: var(--panel-2); }
.quick-row b { display: block; font-size: 12.5px; font-weight: 500; }
.quick-row span { display: block; color: var(--muted); font-size: 11px; margin-top: 1px; }
.quick-row .icon { width: 28px; height: 28px; border-radius: 8px; background: transparent; color: var(--muted); display: flex; align-items: center; justify-content: center; flex: none; }

.stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat-card { padding: 18px 18px 16px; display: flex; flex-direction: column; gap: 4px; }
.stat-card .label { color: var(--muted); font-size: 12px; font-weight: 500; }
.stat-card .value { font-size: 26px; font-weight: 600; letter-spacing: -.4px; line-height: 1.25; font-variant-numeric: tabular-nums; }
.stat-card .sub { color: var(--faint); font-size: 11.5px; }
.stat-card .top { display: flex; align-items: center; justify-content: space-between; }
.stat-icon { width: 28px; height: 28px; border-radius: 8px; display: flex; align-items: center; justify-content: center; background: transparent; color: var(--muted); }
.stat-icon.green { background: transparent; color: var(--muted); }
.stat-icon.amber { background: transparent; color: var(--muted); }
.stat-icon.red { background: transparent; color: var(--muted); }

.dash-grid { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(0, 1fr); gap: 18px; }
.recent-list { display: flex; flex-direction: column; }
.recent-row { display: flex; align-items: center; gap: 12px; padding: 12px 18px; border-top: 1px solid var(--line); cursor: pointer; }
.recent-row:first-child { border-top: 0; }
.recent-row:hover { background: var(--panel-2); }
.recent-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); flex: none; }
.recent-row .t { min-width: 0; flex: 1; }
.recent-row .t b { display: block; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recent-row .t span { display: block; color: var(--muted); font-size: 11px; margin-top: 1px; }
.import-card { padding: 20px; display: flex; flex-direction: column; gap: 10px; }
.import-card .big { font-size: 24px; font-weight: 800; letter-spacing: -.6px; }
.import-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 4px; }
.import-meta div { background: var(--panel-2); border: 1px solid var(--line); border-radius: 9px; padding: 10px; }
.import-meta b { display: block; font-size: 16px; }
.import-meta span { color: var(--muted); font-size: 11px; }

/* ============ Notes workspace ============ */
.notes-ws {
  height: calc(100vh - var(--topbar-h));
  display: grid;
  grid-template-columns: 228px 344px minmax(0, 1fr);
  background: var(--panel);
}
.np-rail { border-right: 1px solid var(--line); background: var(--panel-2); display: flex; flex-direction: column; min-height: 0; }
.np-rail-head { padding: 20px 16px 12px; display: flex; align-items: center; justify-content: space-between; }
.np-rail-head h3 { margin: 0; font-size: 12px; text-transform: uppercase; letter-spacing: .9px; color: var(--muted); }
.rail-list { padding: 0 10px 14px; overflow: auto; display: flex; flex-direction: column; gap: 2px; }
.rail-item { display: flex; align-items: center; gap: 8px; height: 36px; padding: 0 10px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); font-size: 13px; text-align: left; }
.rail-item:hover { background: var(--panel); color: var(--text); }
.rail-item.active { background: var(--panel); color: var(--accent); font-weight: 700; box-shadow: var(--shadow-sm); }
.rail-item .ico { width: 16px; text-align: center; }
.rail-item .cnt { margin-left: auto; font-size: 11px; color: var(--faint); }
.rail-item.drop { outline: 2px solid var(--accent); outline-offset: -2px; background: var(--accent-weak); }
.rail-sep { height: 1px; background: var(--line); margin: 10px 6px; }
.rail-add { margin: 8px 10px 14px; }

.np-list { border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; background: var(--panel); }
.np-list-head { padding: 16px 16px 12px; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 10px; }
.np-search { height: 36px; }
.np-list-meta { display: flex; align-items: center; justify-content: space-between; color: var(--muted); font-size: 11.5px; }
.np-cards { overflow: auto; padding: 8px; display: flex; flex-direction: column; gap: 6px; flex: 1; min-height: 0; }
.note-card {
  position: relative;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 11px 12px 10px 34px;
  cursor: pointer;
  transition: .14s ease;
}
.note-card:hover { background: var(--panel-2); border-color: var(--line); }
.note-card.active { background: var(--accent-weak); border-color: color-mix(in srgb, var(--accent) 35%, transparent); }
.note-card.selected { border-color: var(--line-strong); background: var(--panel-2); }
.note-card.readonly { padding-left: 12px; cursor: default; }
.note-card.dragging { opacity: .45; }
.note-card .chk { position: absolute; left: 10px; top: 13px; width: 15px; height: 15px; accent-color: var(--accent); }
.note-card .title { font-size: 13px; font-weight: 700; line-height: 1.35; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.note-card .snippet { color: var(--muted); font-size: 11.5px; margin-top: 3px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.note-card .meta { display: flex; align-items: center; gap: 6px; margin-top: 6px; color: var(--faint); font-size: 10.5px; }
.note-card .pin { color: var(--warn); }
.note-card .tags { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 6px; }
.note-card .tags span { font-size: 10.5px; color: var(--accent); background: var(--accent-weak); border-radius: 4px; padding: 1px 5px; }
.sel-bar { display: flex; align-items: center; gap: 8px; padding: 8px 8px 0; }
.sel-bar .count { font-size: 11.5px; color: var(--muted); }
.sel-bar .spacer { flex: 1; }

.np-pane { min-width: 0; min-height: 0; display: flex; flex-direction: column; background: var(--panel); }
.editor { display: flex; flex-direction: column; min-height: 0; height: 100%; }
.editor-head { padding: 18px 26px 14px; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 10px; }
.editor-title-row { display: flex; align-items: center; gap: 10px; }
.editor-title {
  flex: 1; min-width: 0; height: 40px; padding: 0; border: 0; outline: none;
  background: transparent; color: var(--text); font-size: 21px; font-weight: 800; letter-spacing: -.5px;
}
.editor-fields { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.editor-fields .input, .editor-fields .select { height: 32px; font-size: 12px; background: var(--panel-2); }
.editor-fields .input.folder { width: 170px; }
.editor-fields .input.tags { width: 250px; }
.editor-toolbar { display: flex; align-items: center; gap: 6px; padding: 8px 26px; border-bottom: 1px solid var(--line); background: var(--panel-2); overflow-x: auto; flex-wrap: nowrap; }
.editor-toolbar .tool-btn { flex: none; white-space: nowrap; }
.editor-toolbar #editor-views { flex: none; }
.tool-btn { height: 28px; padding: 0 8px; border: 1px solid transparent; border-radius: 6px; background: transparent; color: var(--muted); font-size: 12px; }
.tool-btn:hover { background: var(--panel); border-color: var(--line); color: var(--text); }
.save-status { margin-left: auto; color: var(--faint); font-size: 11.5px; }
.save-status.ok { color: var(--ok); }
.save-status.err { color: var(--danger); }
.editor-body { flex: 1; min-height: 0; display: grid; grid-template-columns: 1fr 1fr; }
.editor-body.mode-write { grid-template-columns: 1fr; }
.editor-body.mode-write .md-preview { display: none; }
.editor-body.mode-preview { grid-template-columns: 1fr; }
.editor-body.mode-preview .md-input { display: none; }
.md-input { width: 100%; height: 100%; min-height: 0; padding: 22px 26px; border: 0; outline: none; resize: none; background: var(--panel); color: var(--text); font-family: var(--mono); font-size: 13px; line-height: 1.75; }
.md-preview { overflow: auto; padding: 22px 28px 48px; border-left: 1px solid var(--line); background: var(--panel); font-size: 14px; line-height: 1.75; }
.md-preview h1, .md-preview h2, .md-preview h3 { letter-spacing: -.4px; line-height: 1.35; }
.md-preview h1 { font-size: 24px; margin: 8px 0 14px; }
.md-preview h2 { font-size: 19px; margin: 22px 0 10px; padding-bottom: 5px; border-bottom: 1px solid var(--line); }
.md-preview h3 { font-size: 16px; margin: 18px 0 8px; }
.md-preview p { margin: 8px 0; }
.md-preview ul, .md-preview ol { padding-left: 22px; }
.md-preview blockquote { margin: 12px 0; padding: 8px 14px; border-left: 3px solid var(--accent); background: var(--panel-2); color: var(--muted); }
.md-preview code { background: var(--panel-2); border: 1px solid var(--line); border-radius: 5px; padding: 1px 5px; font-family: var(--mono); font-size: 12.5px; }
.md-preview pre { background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 14px; overflow: auto; }
.md-preview pre code { border: 0; background: transparent; padding: 0; }
.md-preview table { width: 100%; border-collapse: collapse; margin: 12px 0; font-size: 13px; }
.md-preview th, .md-preview td { border: 1px solid var(--line); padding: 7px 10px; text-align: left; }
.md-preview th { background: var(--panel-2); }
.md-preview img { max-width: 100%; border-radius: 10px; margin: 8px 0; border: 1px solid var(--line); }
.md-preview a { text-decoration: underline; text-underline-offset: 2px; }
.md-preview hr { border: 0; border-top: 1px solid var(--line); margin: 18px 0; }
.md-preview .checklist { list-style: none; padding-left: 0; }
.md-preview .checklist li { display: flex; align-items: flex-start; gap: 8px; margin: 5px 0; }
.task-box { width: 17px; height: 17px; margin-top: 3px; border: 1px solid var(--line-strong); border-radius: 4px; background: var(--panel); flex: none; padding: 0; font-size: 11px; line-height: 1; color: var(--ok); }
.task-box.done { background: var(--ok-weak); border-color: var(--ok); }
.editor-foot { border-top: 1px solid var(--line); padding: 12px 26px; display: flex; align-items: center; gap: 8px; background: var(--panel-2); }
.attach-list { display: flex; gap: 6px; flex-wrap: wrap; margin-left: auto; }
.attach-chip { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); font-size: 11px; color: var(--muted); }
.attach-chip button { border: 0; background: transparent; color: var(--faint); padding: 0; font-size: 12px; }
.readonly-banner { padding: 10px 14px; border: 1px solid var(--warn); background: var(--warn-weak); color: var(--warn); border-radius: 9px; font-size: 12.5px; margin: 0 26px 12px; }

/* context menu / active filter */
.ctx-menu {
  position: fixed; z-index: 90;
  min-width: 168px; padding: 5px;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 10px; box-shadow: var(--shadow-lg);
}
.ctx-menu button {
  display: block; width: 100%; padding: 8px 10px;
  border: 0; border-radius: 7px; background: transparent;
  color: var(--text); text-align: left; font-size: 12.5px;
}
.ctx-menu button:hover { background: var(--panel-2); }
.active-filter {
  display: flex; align-items: center; gap: 6px;
  align-self: flex-start; padding: 3px 8px;
  border-radius: 999px; background: var(--accent-weak);
  color: var(--accent); font-size: 11.5px; font-weight: 700;
}
.target-banner {
  padding: 8px 10px; border-radius: 8px;
  background: var(--warn-weak); color: var(--warn);
  font-size: 11.5px; border: 1px solid color-mix(in srgb, var(--warn) 25%, transparent);
}
.active-filter button { border: 0; background: transparent; color: var(--accent); font-size: 14px; line-height: 1; padding: 0; }
.tool-btn.on { background: var(--panel); border-color: var(--line-strong); color: var(--text); box-shadow: var(--shadow-sm); }
.modal-note { white-space: pre-line; }
.preview-frame { width: 100%; height: min(72vh, 860px); border: 0; border-radius: 10px; background: #fff; }

/* ============ Calendar ============ */
.cal-ws {
  height: calc(100vh - var(--topbar-h));
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  background: var(--panel);
}
.cal-main { min-width: 0; display: flex; flex-direction: column; border-right: 1px solid var(--line); }
.cal-toolbar {
  flex: none; height: 62px; padding: 0 22px;
  display: flex; align-items: center; gap: 10px;
  border-bottom: 1px solid var(--line);
}
.cal-month { display: flex; align-items: center; gap: 4px; }
.cal-month h2 { margin: 0 8px; font-size: 20px; letter-spacing: -.6px; }
.cal-month .icon-btn { width: 30px; height: 30px; border: 1px solid var(--line); border-radius: 8px; }
.cal-legend { margin-left: auto; display: flex; gap: 12px; align-items: center; color: var(--muted); font-size: 11.5px; }
.cal-legend i { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 5px; }
.cal-week { flex: none; display: grid; grid-template-columns: repeat(7, 1fr); border-bottom: 1px solid var(--line); background: var(--panel-2); }
.cal-week div { padding: 8px 10px; font-size: 11.5px; font-weight: 700; color: var(--muted); text-align: right; }
.cal-week div:first-child { color: #d14343; }
.cal-week div:last-child { color: #2563eb; }
.cal-grid { flex: 1; min-height: 0; display: grid; grid-template-columns: repeat(7, 1fr); grid-auto-rows: minmax(0, 1fr); overflow: auto; }
.cal-cell {
  min-height: 96px; padding: 7px 8px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 4px; overflow: hidden; cursor: pointer;
  transition: .12s ease;
}
.cal-cell:nth-child(7n) { border-right: 0; }
.cal-cell:hover { background: var(--panel-2); }
.cal-cell.out { background: color-mix(in srgb, var(--panel-2) 70%, transparent); color: var(--faint); }
.cal-cell.today { background: var(--accent-weak); }
.cal-cell.sel { box-shadow: inset 0 0 0 2px var(--accent); }
.cal-cell.drop { background: var(--accent-weak); box-shadow: inset 0 0 0 2px var(--accent); }
.cal-date { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; }
.cal-cell.today .cal-date { color: var(--accent); }
.cal-date .hol { color: var(--danger); font-weight: 600; font-size: 10.5px; }
.cal-ev {
  display: flex; align-items: center; gap: 4px; min-height: 22px; padding: 3px 6px;
  border-radius: 5px; background: var(--accent-weak); color: var(--accent);
  font-size: 11px; font-weight: 600; overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
  cursor: grab;
}
.cal-ev.team { background: var(--ok-weak); color: var(--ok); }
.cal-ev.other { opacity: .72; border: 1px dashed color-mix(in srgb, var(--muted) 40%, transparent); }
.cal-ev.c-green { background: var(--ok-weak); color: var(--ok); }
.cal-ev.c-amber { background: var(--warn-weak); color: var(--warn); }
.cal-ev.c-red { background: var(--danger-weak); color: var(--danger); }
.cal-ev.c-violet { background: #f1ebff; color: #6d3fd1; }
.cal-ev.c-slate { background: var(--panel-2); color: var(--muted); border: 1px solid var(--line); }
[data-theme="dark"] .cal-ev.c-violet { background: #2a2145; color: #b99cff; }
.cal-ev .t { color: inherit; opacity: .8; font-weight: 500; }
.cal-more { color: var(--muted); font-size: 10.5px; padding-left: 4px; }
.cal-side { min-height: 0; display: flex; flex-direction: column; background: var(--panel-2); }
.cal-side-head { padding: 18px 18px 10px; display: flex; align-items: center; gap: 8px; }
.cal-side-head h3 { margin: 0; font-size: 14px; }
.cal-side-head .date { margin-left: auto; color: var(--muted); font-size: 11.5px; }
.cal-day-list { padding: 0 14px 14px; display: flex; flex-direction: column; gap: 6px; max-height: 42%; overflow: auto; }
.cal-day-item { padding: 10px 11px; border: 1px solid var(--line); border-radius: 9px; background: var(--panel); cursor: pointer; }
.cal-day-item:hover { border-color: var(--accent); }
.cal-day-item b { display: block; font-size: 12.5px; }
.cal-day-item span { display: block; color: var(--muted); font-size: 11px; margin-top: 2px; }
.cal-upcoming { flex: 1; min-height: 0; border-top: 1px solid var(--line); padding: 14px; overflow: auto; }
.cal-upcoming h3 { margin: 0 0 9px; font-size: 12px; letter-spacing: .6px; color: var(--muted); text-transform: uppercase; }
.up-row { display: flex; gap: 9px; padding: 8px 4px; border-bottom: 1px solid var(--line); cursor: pointer; }
.up-row:hover { background: var(--panel); }
.up-date { width: 48px; flex: none; text-align: center; color: var(--muted); font-size: 10.5px; }
.up-date b { display: block; color: var(--text); font-size: 15px; line-height: 1.1; }
.up-body { min-width: 0; }
.up-body b { display: block; font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.up-body span { color: var(--muted); font-size: 10.5px; }
@media (max-width: 1366px) {
  .cal-ws { grid-template-columns: minmax(0, 1fr) 300px; }
  .cal-cell { min-height: 80px; }
}
@media (max-width: 1100px) {
  .cal-ws { grid-template-columns: 1fr; }
  .cal-side { display: none; }
}

/* ============ Files ============ */
.files-ws {
  height: calc(100vh - var(--topbar-h));
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  background: var(--panel);
}
.files-tree {
  border-right: 1px solid var(--line);
  background: var(--panel-2);
  display: flex; flex-direction: column; min-height: 0;
}
.files-tree-head { padding: 20px 18px 10px; display: flex; align-items: center; justify-content: space-between; }
.files-tree-head h3 { margin: 0; font-size: 12px; letter-spacing: .9px; text-transform: uppercase; color: var(--muted); }
.files-space-btn {
  display: flex; align-items: center; gap: 9px; width: calc(100% - 20px); margin: 2px 10px;
  height: 38px; padding: 0 11px; border: 0; border-radius: 8px;
  background: transparent; color: var(--muted); font-size: 13px; font-weight: 600; text-align: left;
}
.files-space-btn:hover { background: var(--panel); color: var(--text); }
.files-space-btn.active { background: var(--panel); color: var(--accent); box-shadow: var(--shadow-sm); }
.files-tree-scroll { flex: 1; min-height: 0; overflow: auto; padding: 4px 10px 14px; }
.file-tree-item {
  display: flex; align-items: center; gap: 7px; width: 100%;
  height: 32px; padding: 0 8px; border: 0; border-radius: 7px;
  background: transparent; color: var(--muted); font-size: 12.5px; text-align: left;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.file-tree-item:hover { background: var(--panel); color: var(--text); }
.file-tree-item.active { background: var(--panel); color: var(--accent); font-weight: 700; }
.file-tree-item.drop { outline: 2px solid var(--accent); outline-offset: -2px; background: var(--accent-weak); }
.file-tree-item .ico { width: 15px; text-align: center; flex: none; }
.files-tree-foot { border-top: 1px solid var(--line); padding: 10px; display: flex; flex-direction: column; gap: 4px; }
.files-main { min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.files-toolbar {
  flex: none; min-height: 58px; padding: 10px 22px;
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: var(--panel);
}
.files-crumbs { display: flex; align-items: center; gap: 5px; font-size: 13px; min-width: 0; flex-wrap: wrap; }
.files-crumbs button { border: 0; background: transparent; color: var(--muted); padding: 3px 4px; border-radius: 5px; font-size: 13px; }
.files-crumbs button:hover { background: var(--panel-2); color: var(--accent); }
.files-crumbs b { color: var(--text); font-size: 13px; }
.files-toolbar .sep { width: 1px; height: 20px; background: var(--line); margin: 0 3px; }
.files-search { height: 32px; width: 200px; margin-left: auto; }
.files-body { flex: 1; min-height: 0; overflow: auto; padding: 0 22px 30px; }
.files-body.drag { background: var(--accent-weak); outline: 2px dashed var(--accent); outline-offset: -10px; }
.file-selbar { display: flex; align-items: center; gap: 8px; padding: 9px 2px; min-height: 44px; }
.file-selbar .count { color: var(--muted); font-size: 12px; }
.file-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 12.5px; }
.file-table th {
  position: sticky; top: 0; z-index: 1; background: var(--panel);
  color: var(--muted); font-size: 11.5px; font-weight: 700; text-align: left;
  padding: 10px 10px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
.file-table td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.file-table tr:hover td { background: var(--panel-2); }
.file-table tr.selected td { background: var(--accent-weak); }
.file-name { display: flex; align-items: center; gap: 9px; min-width: 0; cursor: pointer; }
.file-name .ico { width: 26px; height: 26px; border-radius: 7px; background: var(--panel-2); border: 1px solid var(--line); display: flex; align-items: center; justify-content: center; font-size: 13px; flex: none; }
.file-name .txt { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; color: var(--text); }
.file-name:hover .txt { color: var(--accent); }
.file-table .meta { color: var(--muted); font-size: 11.5px; }
.file-row-ops { display: flex; justify-content: flex-end; }
.file-row-ops button { border: 0; background: transparent; color: var(--faint); font-size: 16px; padding: 4px 8px; border-radius: 6px; }
.file-row-ops button:hover { background: var(--panel); color: var(--text); }
.file-empty { padding: 60px 20px; text-align: center; color: var(--faint); font-size: 13px; }
.file-empty.drag { color: var(--accent); }
.file-progress { margin: 10px 0; padding: 10px 12px; border: 1px solid var(--line); border-radius: 9px; background: var(--panel-2); font-size: 12px; color: var(--muted); }
.file-progress .bar { height: 5px; background: var(--line); border-radius: 99px; margin-top: 7px; overflow: hidden; }
.file-progress .bar i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .15s; }
@media (max-width: 1100px) {
  .files-ws { grid-template-columns: 1fr; }
  .files-tree { display: none; }
}

.table-wrap { overflow: auto; }
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 12.5px; }
.table th { position: sticky; top: 0; z-index: 1; background: var(--panel-2); color: var(--muted); font-size: 11.5px; font-weight: 700; text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:hover td { background: var(--panel-2); }
.table .name { font-weight: 700; }
.table .ops { display: flex; gap: 5px; justify-content: flex-end; }
.table .right { text-align: right; }
.role-pill { display: inline-flex; height: 22px; align-items: center; padding: 0 8px; border-radius: 999px; background: var(--panel-2); border: 1px solid var(--line); font-size: 11px; font-weight: 700; }
.role-pill.master { background: #1e293b; color: #fff; border-color: #1e293b; }
.role-pill.admin { background: var(--accent-weak); color: var(--accent); border-color: transparent; }
.role-pill.guest { background: var(--warn-weak); color: var(--warn); border-color: transparent; }

/* ============ Modals / toast ============ */
.modal-backdrop { position: fixed; inset: 0; z-index: 80; background: rgba(8, 15, 28, .55); backdrop-filter: blur(3px); display: flex; align-items: center; justify-content: center; padding: 30px; }
.modal {
  width: 100%; max-width: 480px; max-height: calc(100vh - 60px); overflow: auto;
  background: var(--panel); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow-lg);
  animation: modal-in .16s ease-out;
}
.modal.wide { max-width: 880px; }
@keyframes modal-in { from { transform: translateY(8px) scale(.985); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-head { display: flex; align-items: center; gap: 12px; padding: 20px 22px 0; }
.modal-head h3 { margin: 0; font-size: 17px; letter-spacing: -.3px; }
.modal-body { padding: 18px 22px 8px; display: grid; gap: 14px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 22px 20px; }
.modal-close { margin-left: auto; border: 0; background: transparent; color: var(--faint); font-size: 18px; }
.modal-msg { min-height: 18px; font-size: 12.5px; color: var(--danger); }
.modal-note { padding: 10px 12px; border-radius: 9px; background: var(--panel-2); border: 1px solid var(--line); color: var(--muted); font-size: 12px; }
.toast-root { position: fixed; right: 24px; bottom: 24px; z-index: 100; display: flex; flex-direction: column; gap: 8px; align-items: flex-end; }
.toast { min-width: 240px; max-width: 420px; padding: 12px 14px; border-radius: 10px; background: #101b2e; color: #fff; box-shadow: var(--shadow-lg); font-size: 12.5px; animation: toast-in .18s ease-out; }
.toast.ok { background: #14532d; }
.toast.err { background: #7f1d1d; }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ============ Misc ============ */
.kbd { display: inline-flex; align-items: center; height: 20px; padding: 0 6px; border: 1px solid var(--line-strong); border-bottom-width: 2px; border-radius: 5px; background: var(--panel); color: var(--muted); font-size: 10.5px; font-family: var(--mono); }
.loading { padding: 60px 0; text-align: center; color: var(--faint); font-size: 13px; }
.split { display: flex; gap: 8px; align-items: center; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.section-note { padding: 14px 16px; border: 1px dashed var(--line-strong); border-radius: 10px; color: var(--muted); font-size: 12.5px; background: var(--panel-2); }
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.settings-card { padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.settings-card h3 { margin: 0; font-size: 14px; }
.settings-card .sub { color: var(--muted); font-size: 12px; margin-top: -8px; }
.placeholder { padding: 50px 32px; display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; }
.placeholder .ico { width: 64px; height: 64px; border-radius: 18px; background: var(--accent-weak); color: var(--accent); display: flex; align-items: center; justify-content: center; font-size: 26px; }
.placeholder h2 { margin: 4px 0 0; font-size: 20px; }
.placeholder p { margin: 0; max-width: 620px; color: var(--muted); font-size: 13px; line-height: 1.7; }
.roadmap { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; max-width: 980px; margin-top: 14px; text-align: left; }
.roadmap div { padding: 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); }
.roadmap b { display: block; font-size: 12.5px; margin-bottom: 4px; }
.roadmap span { color: var(--muted); font-size: 11.5px; }

/* ============ Responsive (FHD first) ============ */
@media (max-width: 1600px) {
  :root { --sidebar-w: 228px; }
  .notes-ws { grid-template-columns: 208px 320px minmax(0, 1fr); }
  .view { padding: 22px 24px 36px; }
  .dash-hero { grid-template-columns: minmax(0, 1fr) 310px; }
}
@media (max-width: 1366px) {
  .notes-ws { grid-template-columns: 190px 300px minmax(0, 1fr); }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .dash-grid { grid-template-columns: 1fr; }
  .login-copy h1 { font-size: 42px; }
}
@media (max-width: 1100px) {
  .notes-ws { grid-template-columns: 300px minmax(0, 1fr); }
  .np-rail { display: none; }
  .topbar-search { max-width: 300px; }
  .login-screen { grid-template-columns: 1fr; }
  .login-art { display: none; }
  .login-panel { min-height: 100vh; }
}
@media (max-width: 820px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    display: flex; position: fixed; top: 0; left: 0; bottom: 0;
    width: 248px; z-index: 70; transform: translateX(-100%);
    transition: transform .18s ease-out; box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: none; }
  .nav-toggle { display: inline-flex; }
  .notes-ws { grid-template-columns: 1fr; }
  .notes-ws.note-open .np-list { display: none; }
  .notes-ws:not(.note-open) .np-pane { display: none; }
  .editor-body { grid-template-columns: 1fr; }
  .md-preview { display: none; }
}

/* 파일 상세(정보·버전·댓글) */
.nav-toggle { display: none; }
@media (max-width: 820px) { .nav-toggle { display: inline-flex; } .topbar { gap: 10px; } }
.nav-backdrop { position: fixed; inset: 0; background: rgba(8, 14, 26, .45); z-index: 65; }
@media (min-width: 821px) { .nav-backdrop { display: none; } }
.file-detail { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, .95fr); gap: 20px; }
.file-detail > section { min-width: 0; display: grid; gap: 12px; align-content: start; }
.fd-info { display: grid; gap: 1px; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.fd-row { display: grid; grid-template-columns: 92px 1fr; gap: 10px; padding: 9px 12px; background: var(--panel-2); font-size: 12.5px; }
.fd-row > span { color: var(--muted); }
.fd-row > b { font-weight: 500; word-break: break-all; }
.fd-title { margin: 4px 0 0; font-size: 13px; letter-spacing: -.2px; display: flex; gap: 8px; align-items: baseline; }
.fd-title .muted { font-size: 11.5px; }
.fd-comments { display: grid; gap: 8px; max-height: 240px; overflow: auto; padding-right: 2px; }
.fd-comment { border: 1px solid var(--line); border-radius: 9px; padding: 9px 11px; background: var(--panel-2); }
.fd-comment-head { display: flex; align-items: center; gap: 8px; font-size: 11.5px; color: var(--muted); }
.fd-comment-head b { color: var(--text); font-weight: 600; }
.fd-comment-del { margin-left: auto; border: 0; background: transparent; color: var(--faint); font-size: 15px; line-height: 1; padding: 0 2px; }
.fd-comment-del:hover { color: var(--danger); }
.fd-comment-body { margin-top: 5px; font-size: 12.5px; line-height: 1.55; white-space: pre-wrap; word-break: break-word; }
.fd-comment-form { display: grid; gap: 8px; }
.fd-comment-form textarea { resize: vertical; min-height: 64px; font: inherit; }
.fd-comment-form .btn { justify-self: end; }
@media (max-width: 1100px) { .file-detail { grid-template-columns: 1fr; } }


/* 캘린더 월/주/일 */
.cal-toolbar-right { display: flex; align-items: center; gap: 12px; }
.cal-views { display: inline-flex; gap: 3px; padding: 3px; border: 1px solid var(--line); border-radius: 9px; background: var(--panel-2); }
.cal-views .seg { border: 0; background: transparent; padding: 5px 11px; border-radius: 7px; font-size: 12px; color: var(--muted); cursor: pointer; font: inherit; }
.cal-views .seg.on { background: var(--panel); color: var(--text); font-weight: 600; box-shadow: 0 1px 2px rgba(15, 23, 42, .08); }
.cal-ev .rep { margin-left: 4px; color: var(--faint); font-size: 10px; }

.cal-week-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; padding: 10px 16px 18px; overflow: auto; }
.cw-col { border: 1px solid var(--line); border-radius: 10px; background: var(--panel); display: flex; flex-direction: column; min-height: 340px; min-width: 0; overflow: hidden; }
.cw-col.today { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(37, 99, 235, .12); }
.cw-head { display: flex; align-items: baseline; gap: 6px; padding: 8px 10px; border-bottom: 1px solid var(--line); font-size: 12px; }
.cw-head b { color: var(--muted); font-weight: 600; }
.cw-head span { font-size: 15px; font-weight: 700; }
.cw-head i { font-style: normal; font-size: 10px; color: var(--danger); margin-left: auto; }
.cw-body { display: grid; gap: 5px; padding: 8px; align-content: start; }
.cw-empty { color: var(--faint); font-size: 11px; text-align: center; padding: 6px 0; }
.cw-ev { display: flex; gap: 6px; align-items: baseline; padding: 5px 7px; border-radius: 7px; font-size: 11.5px; cursor: pointer; background: var(--panel-2); border-left: 3px solid var(--accent); min-width: 0; overflow: hidden; }
.cw-ev:hover { background: var(--hover, rgba(15, 23, 42, .04)); }
.cw-ev .t { color: var(--muted); font-size: 10.5px; white-space: nowrap; flex: 0 0 auto; }
.cw-ev .n { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; flex: 1 1 auto; }
.cw-ev .rep { margin-left: auto; color: var(--faint); font-size: 10px; }
.cw-ev.c-green { border-left-color: #15803d; }
.cw-ev.c-amber { border-left-color: #b45309; }
.cw-ev.c-red { border-left-color: #b91c1c; }
.cw-ev.c-violet { border-left-color: #6d28d9; }

.cd-allday { display: flex; gap: 6px; flex-wrap: wrap; padding: 8px 16px 0; }
.cd-grid { padding: 8px 16px 18px; overflow: auto; max-height: calc(100vh - 250px); }
.cd-row { display: grid; grid-template-columns: 56px minmax(0, 1fr); gap: 8px; border-top: 1px solid var(--line); min-height: 34px; }
.cd-row:last-child { border-bottom: 1px solid var(--line); }
.cd-hour { font-size: 11px; color: var(--muted); padding-top: 8px; }
.cd-slot { padding: 4px 0; display: grid; gap: 4px; }
/* 업무 대장 */
.ledger-tabs { display: inline-flex; gap: 3px; padding: 3px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel-2); margin-bottom: 12px; }
.ledger-tabs .seg { border: 0; background: transparent; padding: 7px 14px; border-radius: 8px; font: inherit; font-size: 12.5px; color: var(--muted); cursor: pointer; }
.ledger-tabs .seg.on { background: var(--panel); color: var(--text); font-weight: 600; box-shadow: 0 1px 2px rgba(15,23,42,.08); }
.ledger-tabs .seg b { font-size: 11px; color: var(--faint); font-weight: 600; margin-left: 2px; }
.ledger-tabs .seg.on b { color: var(--accent); }
.ledger-filter { display: flex; gap: 10px; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.ledger-filter .input { max-width: 300px; }
.ledger-filter .spacer { flex: 1; }
.input.sm, .select.sm { height: 32px; font-size: 12px; padding: 0 10px; }
.stat-card.clickable { text-align: left; cursor: pointer; border: 1px solid var(--line); font: inherit; }
.stat-card.clickable:hover { border-color: var(--accent); }
.ledger-stats { margin-top: 14px; }
/* 업무 대장 표: 좁은 화면에서 열 깨짐 방지 */
.ledger-table td, .ledger-table th { white-space: nowrap; }
.ledger-table td.wrap { white-space: normal; min-width: 160px; }
.stat-grid.ledger-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 1100px) { .stat-grid.ledger-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 720px) { .stat-grid.ledger-stats { grid-template-columns: 1fr; } }
/* 규정 양식 칸 */
.reg-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin-bottom: 14px; }
@media (max-width: 860px) { .reg-grid { grid-template-columns: 1fr; } }
.reg-card { padding: 14px 16px; }
.reg-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.reg-head h3 { margin: 0; font-size: 13.5px; letter-spacing: -.2px; }
.reg-head h3 .muted { font-size: 11px; font-weight: 500; }
.reg-head .spacer { flex: 1; }
.reg-list { display: grid; gap: 6px; max-height: 220px; overflow: auto; }
.reg-item { display: flex; align-items: center; gap: 9px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 9px; background: var(--panel-2); }
.reg-item .ico { font-size: 15px; }
.reg-item .t { min-width: 0; flex: 1; display: grid; }
.reg-item .t b { font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reg-item .t span { color: var(--muted); font-size: 11px; }
.reg-item .icon-btn { color: var(--faint); }
.reg-item .icon-btn:hover { color: var(--danger); }
/* 2단계 인증 */
.recovery-box { margin-top: 10px; padding: 12px; border: 1px dashed var(--accent); border-radius: 10px; background: var(--panel-2); display: grid; gap: 8px; }
.recovery-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.recovery-grid .mono { font-size: 13px; letter-spacing: 1px; padding: 5px 8px; background: var(--panel); border: 1px solid var(--line); border-radius: 6px; text-align: center; }
/* ============ 반응형 (B~C) ============ */
.mobile-nav { display: none; }
.note-back { display: none; }
.offline-banner {
  position: fixed; left: 50%; bottom: 14px; transform: translateX(-50%);
  z-index: 120; display: flex; align-items: center; gap: 12px;
  padding: 10px 14px; border-radius: 10px; background: #7f1d1d; color: #fff; font-size: 12.5px;
  box-shadow: var(--shadow-lg);
}
.offline-banner[hidden] { display: none; }
.offline-screen {
  position: fixed; inset: 0; z-index: 130; display: grid; place-items: center;
  background: rgba(8, 14, 26, .6); padding: 20px;
}
.offline-screen[hidden] { display: none; }
.offline-card {
  width: min(460px, 100%); background: var(--panel); border: 1px solid var(--line);
  border-radius: 16px; padding: 26px 24px; text-align: center; box-shadow: var(--shadow-lg);
}
.offline-ico { font-size: 34px; }
.offline-card h2 { margin: 10px 0 8px; font-size: 19px; }
.offline-card p { margin: 0 0 16px; color: var(--muted); font-size: 13px; line-height: 1.6; }
.offline-note { margin-top: 12px; font-size: 11.5px; color: var(--faint); }
.offline-card .btn { min-width: 110px; }

/* 태블릿: 표를 카드형으로 */
@media (max-width: 900px) {
  .card-table thead { display: none; }
  .card-table tbody tr {
    display: block; position: relative; border: 1px solid var(--line); border-radius: 10px;
    margin: 0 0 8px; padding: 10px 12px; background: var(--panel);
  }
  .card-table tbody td {
    display: flex; align-items: center; gap: 10px; justify-content: space-between;
    border: 0; padding: 3px 0; white-space: normal; width: auto !important;
  }
  .card-table tbody td::before { content: attr(data-label); color: var(--muted); font-size: 11px; flex: 0 0 auto; }
  .card-table tbody td[data-label=""]::before { content: none; }
  .card-table tbody td.file-cell-name { padding-right: 40px; }
  .card-table tbody td.file-cell-menu { position: absolute; top: 6px; right: 6px; padding: 0; }
  .card-table tbody td:first-child { position: absolute; top: 10px; left: 10px; width: auto !important; }
  .card-table tbody td.file-cell-name { padding-left: 26px; }
  .file-selbar { flex-wrap: wrap; }
}

/* 모바일: 하단 탭 + 전체화면 모달 */
@media (max-width: 720px) {
  .app { padding-bottom: 60px; }
  .mobile-nav {
    display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0;
    height: 58px; background: var(--panel); border-top: 1px solid var(--line); z-index: 75;
    padding-bottom: env(safe-area-inset-bottom);
  }
  .mn-item {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    border: 0; background: transparent; font: inherit; font-size: 10.5px; color: var(--muted);
  }
  .mn-item .ico { font-size: 17px; line-height: 1; }
  .mn-item.active { color: var(--accent); font-weight: 600; }
  .mobile-nav { box-shadow: 0 -2px 10px rgba(15, 23, 42, .06); }

  .view { padding: 10px 12px 78px; }
  .topbar { padding: 8px 12px; gap: 8px; }
  .topbar-search { display: none; }
  .crumb { font-size: 16px; }
  .crumb-sub { display: none; }
  .topbar-actions { gap: 6px; }
  .topbar-actions .btn { padding: 7px 10px; font-size: 12px; }

  .page-head { padding: 8px 2px 0; flex-direction: column; align-items: flex-start; gap: 8px; }
  .page-head h2 { font-size: 19px; }
  .page-head p { font-size: 12px; }

  .modal { width: calc(100vw - 16px); max-width: none; max-height: calc(100vh - 20px); border-radius: 14px; }
  .modal-head { padding: 16px 16px 0; }
  .modal-body { padding: 14px 16px 6px; }
  .modal-foot { padding: 12px 16px 16px; flex-wrap: wrap; gap: 8px; }
  .modal-foot .btn { flex: 1 1 42%; }
  .modal-body .grid-2 { grid-template-columns: 1fr; }

  .notes-ws { grid-template-columns: 1fr; }
  .notes-ws.note-open .np-list { display: none; }
  .notes-ws:not(.note-open) .np-pane { display: none; }
  .np-list { border-right: 0; }
  .note-back { display: inline-flex; }
  .editor-body { grid-template-columns: 1fr; }
  .md-preview { display: none; }
  .editor-body.mode-split .md-input { display: block; }
  .editor-foot { flex-wrap: wrap; gap: 6px; }
  .editor-title { font-size: 19px; }

  .cal-toolbar { flex-wrap: wrap; gap: 8px; }
  .cal-month h2 { font-size: 15px; }
  .cal-ws { grid-template-columns: 1fr; }
  .cal-side { display: none; }
  .cal-week-grid { gap: 4px; padding: 6px; }
  .cal-views .seg { padding: 4px 8px; font-size: 11.5px; }

  .files-toolbar { flex-wrap: wrap; gap: 6px; padding: 8px 10px; }
  .files-toolbar .files-search { width: 100%; }
  .files-crumbs { flex-wrap: wrap; }
  .glass, .dash-hero { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .dash-grid { grid-template-columns: 1fr; }
  .hero-card { padding: 20px; }
  .hero-card h2 { font-size: 22px; }

  .toast-root { left: 12px; right: 12px; bottom: 70px; }
  .toast { min-width: 0; width: 100%; }
  .offline-banner { left: 10px; right: 10px; transform: none; bottom: 68px; justify-content: space-between; }
}

@media (min-width: 721px) {
  .mobile-nav { display: none; }
.note-back { display: none; }
}

/* 오프라인일 때 저장 버튼 흐리게 */
body.is-offline .btn.primary { opacity: .55; }

/* 터치 편의 */
@media (pointer: coarse) {
  .nav-item, .rail-item, .mn-item, .btn, .icon-btn { min-height: 38px; }
  .file-row-ops button { width: 34px; height: 34px; }
}
/* ============ unslop: 아이콘·숫자·여백 정리 ============ */
.ic { display: inline-block; vertical-align: -3px; flex: none; }
.quick-row .ic, .stat-icon .ic, .file-name .ic, .reg-item .ic { color: inherit; }
.file-name .ic { color: var(--muted); }
.files-space-btn svg, .rail-item svg { flex: none; }
.value, .big, .mono, .sub, td.meta, .meta, .up-date b, .cal-date span { font-variant-numeric: tabular-nums; }
h1, h2, h3, h4, .hero-card h2 { letter-spacing: -.2px; }
.section-note, .sub, .muted { letter-spacing: 0; }
.btn { border-radius: 9px; }
.panel { border-radius: 14px; }
.modal { border-radius: 16px; }
.input, .select, .textarea { border-radius: 9px; }
.badge { border-radius: 6px; font-weight: 500; }
.panel-head h3, .card h3 { font-weight: 600; }
.card-title, .page-head h2 { font-weight: 600; letter-spacing: -.3px; }
/* 수치/일자 정렬 */
.stat-card .sub { font-size: 11.5px; }
table.table td.mono, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
/* 업무 대장: 새 항목 아래 아이콘 */
.ledger-actions { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.ledger-tab-ico { color: var(--muted); line-height: 0; }
.ledger-actions .btn { min-width: 104px; }

/* 규정 양식 접기/펼치기 */
.reg-card { padding: 0; }
.reg-card .reg-head { padding: 12px 16px; margin: 0; }
.reg-card.collapsed .reg-head { border-bottom: 0; }
.reg-card .reg-list { padding: 0 16px 14px; }
.reg-head h3.reg-title { margin: 0; display: flex; min-width: 0; }
.reg-toggle {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 26px; padding: 3px 9px 3px 4px; margin-left: -4px;
  border: 0; background: transparent; color: var(--text);
  border-radius: 7px; font: inherit; font-size: 13.5px; line-height: 1.25;
  white-space: nowrap; text-align: left; cursor: pointer;
}
.reg-toggle:hover { background: var(--panel-2); }
.reg-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.reg-chev { display: inline-flex; color: var(--muted); line-height: 0; }
.reg-name { font-size: 13.5px; font-weight: 700; letter-spacing: -.2px; }
.reg-toggle .muted { font-size: 11px; font-weight: 500; }
.reg-toggle .badge { pointer-events: none; }

/* 회계장부 숫자 정렬 */
.ledger-table th.num, .ledger-table td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }