/* macOS Finder (light) clone */
:root {
  --text: #1d1d1f;
  --text-secondary: #6e6e73;
  --muted: #8e8e93;

  --accent: #0a84ff;
  --accent-hover: #3395ff;
  --danger: #ff3b30;
  --ok: #30a46c;
  --warn: #ff9500;

  --window-bg: rgba(246, 246, 246, 0.88);
  --sidebar-bg: rgba(235, 235, 238, 0.82);
  --toolbar-bg: rgba(236, 236, 238, 0.85);
  --content-bg: #ffffff;

  --border: rgba(0, 0, 0, 0.08);
  --border-strong: rgba(0, 0, 0, 0.12);
  --separator: rgba(0, 0, 0, 0.06);

  --row-hover: rgba(0, 0, 0, 0.025);
  --row-selected: #0a84ff;
  --row-selected-inactive: rgba(0, 0, 0, 0.08);

  --c-folder: #7cb7ff;
  --c-html: #ff9f6b;
  --c-code: #0a84ff;
  --c-text-color: #636366;
  --c-pdf: #ff3b30;
  --c-image: #30a46c;
  --c-video: #af52de;
  --c-audio: #ff9500;
  --c-zip: #ffcc00;

  --traffic-red: #ff5f57;
  --traffic-yellow: #febc2e;
  --traffic-green: #28c840;

  --shadow-window: 0 24px 80px rgba(0, 0, 0, 0.28), 0 2px 6px rgba(0, 0, 0, 0.15);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.1);
  --shadow-md: 0 8px 32px rgba(0, 0, 0, 0.2);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Helvetica Neue", "Noto Sans KR", sans-serif;
  font-size: 13px;
  color: var(--text);
  min-height: 100vh;
  padding: 32px 20px 20px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  letter-spacing: -0.005em;
  /* Sonoma 벽지 느낌 (파랑-오렌지 그라데이션) */
  background:
    radial-gradient(ellipse at 50% 70%, #ff9f5a 0%, transparent 40%),
    radial-gradient(ellipse at 20% 20%, #2b5cff 0%, transparent 50%),
    radial-gradient(ellipse at 80% 30%, #1e3fb5 0%, transparent 60%),
    linear-gradient(160deg, #0d2f8f 0%, #244adb 40%, #ff8a3c 100%);
  background-attachment: fixed;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }
::selection { background: rgba(10, 132, 255, 0.25); }

/* ==================== Finder Window ==================== */
.window {
  max-width: 1280px;
  margin: 0 auto;
  background: var(--window-bg);
  backdrop-filter: saturate(180%) blur(30px);
  -webkit-backdrop-filter: saturate(180%) blur(30px);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: var(--shadow-window);
  display: grid;
  grid-template-columns: 200px 1fr;
  grid-template-rows: 52px auto 1fr 28px;
  min-height: calc(100vh - 64px);
  border: 0.5px solid rgba(255, 255, 255, 0.2);
}

/* ==================== Titlebar ==================== */
.titlebar {
  grid-column: 1 / 3;
  display: flex; align-items: center;
  padding: 0 16px;
  background: var(--toolbar-bg);
  border-bottom: 0.5px solid var(--separator);
  user-select: none;
  gap: 10px;
}
.traffic-lights { display: inline-flex; gap: 8px; align-items: center; }
.tl { width: 12px; height: 12px; border-radius: 50%; display: inline-block; box-shadow: inset 0 0 0 0.5px rgba(0, 0, 0, 0.12); }
.tl.red    { background: var(--traffic-red); }
.tl.yellow { background: var(--traffic-yellow); }
.tl.green  { background: var(--traffic-green); }

.titlebar-nav { display: inline-flex; gap: 2px; margin-left: 18px; }
.nav-btn {
  width: 28px; height: 26px; display: inline-flex; align-items: center; justify-content: center;
  background: transparent; border: none; border-radius: 5px;
  color: var(--text-secondary); cursor: pointer;
  transition: background 0.08s;
}
.nav-btn:hover { background: rgba(0, 0, 0, 0.06); color: var(--text); }
.nav-btn.disabled { color: rgba(0, 0, 0, 0.25); pointer-events: none; }
.nav-btn .icon { width: 14px; height: 14px; }

.titlebar-title {
  flex: 1; text-align: center;
  font-size: 13px; font-weight: 600;
  color: var(--text); letter-spacing: -0.01em;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.titlebar-title .icon { width: 14px; height: 14px; vertical-align: -2px; margin-right: 3px; color: var(--c-folder); }
.tb-path a { color: var(--text); font-weight: 500; }
.tb-path a:hover { color: var(--accent); }
.tb-path a:last-child { color: var(--text); pointer-events: none; }
.tb-sep { color: var(--muted); margin: 0 4px; font-weight: 400; }

.titlebar-tools { display: inline-flex; gap: 1px; align-items: center; }
.tool-btn {
  width: 30px; height: 26px; display: inline-flex; align-items: center; justify-content: center;
  background: transparent; border: none; border-radius: 5px;
  color: var(--text); cursor: pointer;
  transition: background 0.08s;
}
.tool-btn:hover { background: rgba(0, 0, 0, 0.06); }
.tool-btn .icon { width: 15px; height: 15px; color: var(--text-secondary); }
.tool-btn .icon-chev { width: 9px; height: 9px; margin-left: 1px; color: var(--muted); }
.tool-btn.search { width: auto; padding: 0 6px; }

.view-segment {
  display: inline-flex;
  background: rgba(0, 0, 0, 0.04);
  border-radius: 6px;
  padding: 2px;
  gap: 1px;
}
.view-segment .view-btn { width: 28px; height: 22px; border-radius: 4px; }
.view-segment .view-btn.active { background: #fff; box-shadow: 0 0.5px 1px rgba(0, 0, 0, 0.2); }
.view-segment .view-btn.active .icon { color: var(--text); }

.titlebar-user {
  margin-left: 10px; padding-left: 10px;
  border-left: 0.5px solid var(--separator);
  color: var(--text-secondary); font-size: 12px;
  display: inline-flex; align-items: center; gap: 6px;
}
.titlebar-user a { color: var(--text-secondary); display: inline-flex; align-items: center; gap: 3px; }
.titlebar-user a:hover { color: var(--text); }
.titlebar-user .icon { width: 12px; height: 12px; }

/* ==================== Sidebar ==================== */
.sidebar {
  background: var(--sidebar-bg);
  border-right: 0.5px solid var(--separator);
  padding: 8px 0;
  overflow-y: auto;
  grid-row: 2 / 4;
}
.sidebar-section {
  padding: 10px 14px 4px;
  font-size: 11px; font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.01em;
}
.sidebar-item {
  display: flex; align-items: center; gap: 7px;
  padding: 3px 14px;
  font-size: 13px; color: var(--text);
  cursor: pointer; user-select: none;
  border-radius: 0;
  height: 24px;
}
.sidebar-item:hover { background: rgba(0, 0, 0, 0.03); }
.sidebar-item.active {
  background: rgba(0, 0, 0, 0.1);
}
.sidebar-item .icon { width: 16px; height: 16px; color: var(--accent); flex-shrink: 0; }
.sidebar-item .sb-label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
a.sidebar-item { color: var(--text); text-decoration: none; }
a.sidebar-item:hover { color: var(--text); }
.sidebar-item.open .icon-chev { transform: rotate(180deg); }
.sidebar-item .icon-chev { transition: transform 0.15s; }

.sidebar-sub { margin-bottom: 2px; }
.sidebar-sub-item { font-size: 12px; padding-left: 30px !important; height: 22px; color: var(--text-secondary); }
.sidebar-sub-item .icon { width: 12px; height: 12px; color: var(--muted); }
.sidebar-empty { padding: 4px 14px 4px 30px; font-size: 12px; color: var(--muted); font-style: italic; }

/* ==================== Content area ==================== */
.content {
  background: var(--content-bg);
  overflow: auto;
  display: flex; flex-direction: column;
  min-height: 0;
  grid-row: 2 / 4;
}

/* List view column header — Finder와 동일하게 */
.list-header {
  position: sticky; top: 0; z-index: 2;
  display: grid;
  grid-template-columns: 26px 1fr 110px 120px 170px 130px;
  gap: 0;
  background: #f0f0f2;
  border-bottom: 0.5px solid var(--border);
  font-size: 11px; font-weight: 500;
  color: var(--text-secondary);
  user-select: none;
}
.list-header > div {
  padding: 4px 10px;
  border-right: 0.5px solid var(--separator);
  display: flex; align-items: center;
}
.list-header > div:last-child { border-right: none; }
.list-header .sortable { cursor: pointer; }
.list-header .sortable:hover { background: rgba(0, 0, 0, 0.04); color: var(--text); }
.list-header .sort-active { color: var(--text); }
.list-header .sort-ind { margin-left: 3px; font-size: 9px; color: var(--accent); }

/* File list */
.file-list { flex: 1; overflow: visible; }
.file-row {
  display: grid;
  grid-template-columns: 26px 1fr 110px 120px 170px 130px;
  gap: 0;
  align-items: center;
  font-size: 13px;
  border-bottom: 0.5px solid var(--separator);
  transition: background 0.05s;
}
.file-row.parent { color: var(--text-secondary); }
.file-row > div { padding: 3px 10px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.file-row > div.actions-cell { padding: 1px 8px; text-align: right; }
.file-row:hover { background: var(--row-hover); }
.file-row.selected {
  background: var(--row-selected);
  color: #fff;
}
.file-row.selected .muted,
.file-row.selected .row-name { color: #fff; }
.file-row.selected .row-name .icon { filter: brightness(0) invert(1); }
.file-row.selected .row-name .thumb { box-shadow: 0 0 0 1.5px #fff; }
.file-row.selected .visibility-select {
  background-color: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.4);
  color: #fff;
}
.file-row.selected .btn { border-color: rgba(255, 255, 255, 0.4); color: #fff; background: rgba(255, 255, 255, 0.15); }
.file-row.selected .btn-danger { color: #fff; }

.check-cell { padding: 0 0 0 8px !important; }

.row-name { display: inline-flex; align-items: center; gap: 7px; color: inherit; overflow: hidden; }
.row-name:hover { color: inherit; }
.row-name .icon { width: 17px; height: 17px; flex-shrink: 0; }
.row-name .thumb {
  width: 18px; height: 18px; border-radius: 2px;
  object-fit: cover; background: #eee; flex-shrink: 0;
  box-shadow: 0 0 0 0.5px var(--border);
}
.name-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

[hidden] { display: none !important; }

/* ==================== Grid view ==================== */
.content.view-grid .list-header { display: none; }
.content.view-grid .file-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 8px;
  padding: 16px;
}
.content.view-grid .file-row {
  display: flex; flex-direction: column;
  align-items: center;
  padding: 10px 6px;
  border: none;
  border-radius: 8px;
  text-align: center;
  gap: 6px;
  cursor: default;
  min-height: 120px;
}
.content.view-grid .file-row:hover { background: var(--row-hover); }
.content.view-grid .file-row.selected { background: var(--row-selected); color: #fff; }
.content.view-grid .file-row.selected .muted { color: #fff; }
.content.view-grid .file-row > div { padding: 0; white-space: normal; overflow: visible; }
.content.view-grid .check-cell { position: absolute; top: 6px; left: 6px; padding: 0 !important; z-index: 1; }
.content.view-grid .file-row { position: relative; }
.content.view-grid .row-name {
  flex-direction: column; gap: 6px;
  width: 100%;
}
.content.view-grid .row-name .icon { width: 48px; height: 48px; }
.content.view-grid .row-name .thumb {
  width: 64px; height: 64px; border-radius: 6px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
  image-rendering: -webkit-optimize-contrast;
}
.content.view-grid .name-text {
  font-size: 12px; line-height: 1.3;
  max-width: 100%; word-break: break-word; white-space: normal;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}
.content.view-grid .file-row > div:nth-child(3),
.content.view-grid .file-row > div:nth-child(4),
.content.view-grid .file-row > div:nth-child(5) { display: none; }
.content.view-grid .actions-cell { display: none; }

/* ==================== Status bar (하단) ==================== */
.statusbar {
  grid-column: 1 / 3;
  background: var(--toolbar-bg);
  border-top: 0.5px solid var(--separator);
  font-size: 11px; color: var(--text-secondary);
  display: flex; align-items: center; justify-content: center;
  gap: 10px;
  user-select: none;
  padding: 0 14px;
}
.statusbar .sep { color: var(--muted); }
.statusbar .path-segment { display: inline-flex; align-items: center; gap: 3px; }
.statusbar .path-segment .icon { width: 11px; height: 11px; color: var(--c-folder); }
.statusbar .path-segment::after {
  content: '›'; color: var(--muted); margin-left: 6px;
}
.statusbar .path-segment:last-child::after { content: ''; margin: 0; }

/* ==================== Icons ==================== */
.icon { width: 1em; height: 1em; vertical-align: -0.15em; flex-shrink: 0; }
.icon-lg { width: 18px; height: 18px; }
.icon-xl { width: 36px; height: 36px; }

.icon--folder { color: var(--c-folder); }
.icon--html   { color: var(--c-html); }
.icon--code   { color: var(--c-code); }
.icon--text   { color: var(--c-text-color); }
.icon--pdf    { color: var(--c-pdf); }
.icon--image  { color: var(--c-image); }
.icon--video  { color: var(--c-video); }
.icon--audio  { color: var(--c-audio); }
.icon--zip    { color: var(--c-zip); }
.icon--file   { color: var(--muted); }

/* ==================== Buttons (모달/드롭존용) ==================== */
.btn {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 11px;
  border-radius: 6px;
  border: 0.5px solid var(--border-strong);
  background: #fff;
  color: var(--text); cursor: pointer;
  font-size: 13px; font-family: inherit; font-weight: 400;
  transition: background 0.08s;
  white-space: nowrap; line-height: 1.6;
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.04);
}
.btn:hover { background: #f4f4f5; color: var(--text); }
.btn:active { background: #e8e8ea; }
.btn .icon { width: 12px; height: 12px; color: var(--text-secondary); }

.btn-primary {
  background: linear-gradient(180deg, #3a95ff, #0a84ff);
  color: #fff; border-color: rgba(10, 132, 255, 0.9); font-weight: 500;
  box-shadow: 0 0.5px 0 rgba(255, 255, 255, 0.3) inset, 0 1px 1px rgba(0, 0, 0, 0.15);
}
.btn-primary:hover { background: linear-gradient(180deg, #4fa3ff, #2494ff); color: #fff; }
.btn-primary .icon { color: #fff; }

.btn-danger { color: var(--danger); }
.btn-danger:hover { background: rgba(255, 59, 48, 0.08); color: var(--danger); border-color: rgba(255, 59, 48, 0.35); }
.btn-danger .icon { color: var(--danger); }

.btn-icon { padding: 2px 6px; }
.btn-icon .icon { width: 13px; height: 13px; }

/* ==================== Inputs ==================== */
input[type=text], input[type=password], input[type=file] {
  background: #fff;
  color: var(--text);
  border: 0.5px solid var(--border-strong);
  border-radius: 5px;
  padding: 4px 8px; font-size: 13px; width: 100%;
  font-family: inherit;
  transition: border-color 0.1s, box-shadow 0.1s;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.03);
}
input:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(10, 132, 255, 0.2);
}

/* Checkbox */
input[type=checkbox] {
  -webkit-appearance: none; appearance: none;
  width: 13px; height: 13px;
  border: 0.5px solid var(--border-strong);
  border-radius: 3px;
  background: #fff;
  cursor: pointer; position: relative; margin: 0;
  vertical-align: middle;
  transition: background 0.08s;
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.04);
}
input[type=checkbox]:checked { background: var(--accent); border-color: var(--accent); }
input[type=checkbox]:checked::after {
  content: ''; position: absolute;
  left: 3px; top: 0.5px; width: 3.5px; height: 7px;
  border: solid white; border-width: 0 1.7px 1.7px 0;
  transform: rotate(45deg);
}
input[type=checkbox]:indeterminate { background: var(--accent); border-color: var(--accent); }
input[type=checkbox]:indeterminate::after {
  content: ''; position: absolute;
  left: 2px; top: 5px; width: 7px; height: 1.5px; background: white;
}

/* Visibility select */
.visibility-select {
  background: #fff;
  color: var(--text);
  border: 0.5px solid var(--border-strong);
  border-radius: 5px;
  padding: 2px 20px 2px 8px; font-size: 12px; cursor: pointer;
  font-family: inherit;
  appearance: none; -webkit-appearance: none; -moz-appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='9' height='9' viewBox='0 0 24 24' fill='none' stroke='%236e6e73' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat: no-repeat; background-position: right 6px center;
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.04);
  height: 20px;
}
.visibility-select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(10, 132, 255, 0.2); }
.visibility-select.public,
.visibility-select.v-public { color: var(--ok); border-color: rgba(48, 163, 108, 0.5); }
.visibility-select.v-readonly { color: var(--warn); border-color: rgba(255, 149, 0, 0.5); }
.visibility-select.v-private { color: var(--text-secondary); }
.visibility-select option { background: #fff; color: var(--text); }

/* ==================== Search in titlebar ==================== */
.search-wrap {
  position: relative;
  display: inline-flex; align-items: center;
  width: 160px;
}
.search-wrap .icon {
  position: absolute; left: 7px; width: 11px; height: 11px;
  color: var(--muted); pointer-events: none;
}
.search-wrap input {
  padding: 3px 8px 3px 24px;
  background: #fff;
  border-radius: 6px;
  font-size: 12px; height: 22px;
}

/* ==================== Selection bar ==================== */
.selection-bar {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  padding: 6px 14px;
  background: rgba(10, 132, 255, 0.08);
  border-bottom: 0.5px solid var(--separator);
  font-size: 12px; color: var(--text);
}
.selection-bar .btn { padding: 2px 9px; font-size: 12px; }
.bulk-visibility-group {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 2px 8px;
  background: rgba(255, 255, 255, 0.6);
  border: 0.5px solid var(--separator);
  border-radius: 6px;
}
.bulk-visibility-group label { margin: 0; }
.bulk-visibility-group .visibility-select { font-size: 12px; padding: 2px 6px; }

.muted { color: var(--muted); font-size: 12px; }

/* ==================== Drop Zone ==================== */
.drop-zone {
  margin: 14px 16px;
  border: 1.5px dashed var(--border-strong);
  border-radius: 8px;
  padding: 22px 20px; text-align: center;
  color: var(--text-secondary);
  transition: border-color 0.15s, background 0.15s;
  background: rgba(0, 0, 0, 0.015);
}
.drop-zone.drag {
  border-color: var(--accent);
  background: rgba(10, 132, 255, 0.06);
  color: var(--text);
}
.drop-zone .icon-xl { color: var(--muted); margin-bottom: 6px; }
.drop-zone.drag .icon-xl { color: var(--accent); }
.drop-zone .actions { display: inline-flex; gap: 6px; flex-wrap: wrap; justify-content: center; margin-top: 10px; align-items: center; }
.btn-sep { width: 1px; height: 18px; background: var(--border); margin: 0 4px; }

.btn-upload:disabled {
  background: #e5e5ea;
  color: var(--muted);
  border-color: var(--border-strong);
  box-shadow: none;
  cursor: not-allowed;
}
.btn-upload:disabled .icon { color: var(--muted); }

.enter-hint {
  display: inline-flex; align-items: center; gap: 4px;
  margin-left: 6px;
  padding: 1px 7px;
  border-radius: 4px;
  background: rgba(10, 132, 255, 0.1);
  color: var(--accent);
  font-size: 11px;
  font-weight: 500;
  border: 0.5px solid rgba(10, 132, 255, 0.3);
}
.kbd {
  display: inline-block;
  font-family: -apple-system-ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 10px; font-weight: 600;
  padding: 0 4px;
  background: #fff;
  border-radius: 3px;
  box-shadow: inset 0 -1px 0 rgba(0,0,0,0.1), 0 0 0 0.5px rgba(0,0,0,0.12);
}
.drop-zone-title { font-size: 13px; color: var(--text); margin-bottom: 4px; font-weight: 500; }
.drop-zone-desc { font-size: 12px; color: var(--muted); }

/* 진행률 */
.progress { position: relative; margin: 10px 40px 0; height: 4px; background: rgba(0, 0, 0, 0.08); border-radius: 2px; overflow: hidden; }
.progress-fill { height: 100%; width: 0%; background: linear-gradient(90deg, var(--accent), var(--accent-hover)); transition: width 0.15s ease-out; border-radius: 2px; }
.progress-text { margin-top: 4px; font-size: 11px; color: var(--text-secondary); text-align: center; }

/* ==================== New folder inline row ==================== */
.file-row.new-folder { background: rgba(10, 132, 255, 0.06); }
.new-folder-input {
  background: #fff;
  border: 1px solid var(--accent) !important;
  border-radius: 3px;
  padding: 1px 6px !important;
  font-size: 13px;
  font-family: inherit;
  color: var(--text);
  min-width: 180px;
  box-shadow: 0 0 0 2px rgba(10, 132, 255, 0.25);
}
.new-folder-input:focus { outline: none; }
.content.view-grid .new-folder-input { text-align: center; min-width: 100px; max-width: 100%; }

/* ==================== Flash ==================== */
.flash { padding: 6px 10px; border-radius: 5px; margin: 8px 16px; font-size: 12px; }
.flash-ok { background: rgba(48, 163, 108, 0.12); border: 0.5px solid var(--ok); color: var(--ok); }
.flash-err { background: rgba(255, 59, 48, 0.12); border: 0.5px solid var(--danger); color: var(--danger); }

/* ==================== Login window ==================== */
.login-body { display: flex; align-items: center; justify-content: center; min-height: calc(100vh - 64px); }
.login-window {
  width: 320px;
  background: var(--window-bg);
  backdrop-filter: saturate(180%) blur(30px);
  border: 0.5px solid rgba(255, 255, 255, 0.3);
  border-radius: 10px;
  box-shadow: var(--shadow-window);
  padding: 36px 30px 24px;
  text-align: center;
}
.login-window .login-logo { margin-bottom: 16px; }
.login-window .login-logo .icon-xl { color: var(--accent); width: 52px; height: 52px; }
.login-window .login-logo-text { font-size: 18px; font-weight: 600; margin-top: 6px; letter-spacing: -0.02em; }
.login-window form { text-align: left; }
.login-window label { display: block; margin-bottom: 4px; color: var(--text-secondary); font-size: 12px; font-weight: 500; }
.login-window input { margin-bottom: 12px; padding: 6px 9px; font-size: 13px; }
.login-window .btn-primary { width: 100%; padding: 6px; justify-content: center; font-size: 13px; margin-top: 4px; }

/* ==================== Viewer ==================== */
.viewer-window {
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
  background: var(--window-bg);
  backdrop-filter: saturate(180%) blur(30px);
  -webkit-backdrop-filter: saturate(180%) blur(30px);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: var(--shadow-window);
  border: 0.5px solid rgba(255, 255, 255, 0.2);
  height: calc(100vh - 64px);
  display: grid;
  grid-template-rows: 52px 1fr;
}
.viewer-titlebar {
  display: flex; align-items: center; gap: 12px;
  padding: 0 16px;
  background: var(--toolbar-bg);
  border-bottom: 0.5px solid var(--separator);
  user-select: none;
}
.viewer-title {
  flex: 1; display: inline-flex; align-items: center; gap: 8px;
  font-size: 13px; font-weight: 600; overflow: hidden;
}
.viewer-title .icon { width: 15px; height: 15px; flex-shrink: 0; }
.viewer-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.viewer-meta { color: var(--text-secondary); font-size: 11px; font-weight: 400; margin-left: 6px; }
.viewer-actions { display: inline-flex; gap: 6px; align-items: center; }
.viewer-actions .btn {
  padding: 4px 12px;
  font-size: 12px;
  height: 26px;
  line-height: 1;
  align-items: center;
}
.viewer-actions .btn .icon { width: 13px; height: 13px; }
.viewer-actions .btn-icon-only { padding: 4px 8px; min-width: 28px; justify-content: center; }

.visibility-badge {
  padding: 2px 8px; border-radius: 10px;
  font-size: 11px; font-weight: 500;
  border: 0.5px solid;
}
.visibility-badge.v-readonly { background: rgba(255, 149, 0, 0.12); color: var(--warn); border-color: rgba(255, 149, 0, 0.4); }
.visibility-badge.v-public { background: rgba(48, 163, 108, 0.12); color: var(--ok); border-color: rgba(48, 163, 108, 0.4); }

.viewer-frame {
  background: #1c1c1e;
  overflow: hidden;
  display: flex; align-items: stretch; justify-content: stretch;
  min-height: 0;
}
.viewer-frame[data-kind="text"],
.viewer-frame[data-kind="html"],
.viewer-frame[data-kind="pdf"],
.viewer-frame[data-kind="zip"],
.viewer-frame[data-kind="markdown"] { background: #fff; }

.media-wrap { flex: 1; display: flex; align-items: center; justify-content: center; padding: 16px; overflow: auto; }
.media-image { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 4px; box-shadow: 0 4px 16px rgba(0,0,0,0.3); }
.media-video { max-width: 100%; max-height: 100%; border-radius: 4px; box-shadow: 0 4px 16px rgba(0,0,0,0.3); background: #000; }
.audio-wrap { flex-direction: column; gap: 14px; color: #fff; padding: 40px 20px; justify-content: center; }
.audio-name { font-size: 14px; font-weight: 500; text-align: center; word-break: break-all; }
.media-audio { width: min(420px, 90%); }
.media-pdf { flex: 1; width: 100%; border: none; background: #fff; }
.media-iframe { flex: 1; width: 100%; border: none; background: #fff; }

/* ==================== Markdown (Notion-like) ==================== */
.md-wrap { flex: 1; background: #ffffff; overflow: auto; }
.md-content {
  max-width: 760px;
  margin: 0 auto;
  padding: 56px 56px 96px;
  color: #37352f;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "SF Pro Text", "Helvetica Neue", "Noto Sans KR", sans-serif;
  font-size: 16px; line-height: 1.7;
  word-break: keep-all;
}
.md-loading { color: var(--muted); font-size: 13px; padding: 20px; text-align: center; }

.md-content h1, .md-content h2, .md-content h3,
.md-content h4, .md-content h5, .md-content h6 {
  margin: 1.6em 0 0.4em; line-height: 1.3;
  color: #37352f; letter-spacing: -0.01em;
}
.md-content h1 { font-size: 2em; font-weight: 700; padding-bottom: 0.3em; border-bottom: 1px solid rgba(55,53,47,0.12); }
.md-content h2 { font-size: 1.5em; font-weight: 600; }
.md-content h3 { font-size: 1.25em; font-weight: 600; }
.md-content h4 { font-size: 1.05em; font-weight: 600; }
.md-content h5, .md-content h6 { font-size: 1em; font-weight: 600; color: rgba(55,53,47,0.65); }
.md-content > *:first-child { margin-top: 0; }

.md-content p { margin: 0.5em 0 0.8em; }

.md-content a { color: #2383e2; text-decoration: underline; text-underline-offset: 2px; }
.md-content a:hover { color: #1a6cb6; }

.md-content strong { font-weight: 600; }
.md-content em { font-style: italic; }
.md-content del { color: rgba(55,53,47,0.5); }

.md-content ul, .md-content ol { margin: 0.4em 0 0.9em; padding-left: 1.6em; }
.md-content li { margin: 0.15em 0; }
.md-content li > ul, .md-content li > ol { margin: 0.2em 0; }
.md-content li > p { margin: 0.2em 0; }

/* 작업 목록 (- [ ] / - [x]) */
.md-content input[type=checkbox] {
  margin-right: 8px; vertical-align: -1px;
  width: 14px; height: 14px;
}
.md-content li:has(input[type=checkbox]) { list-style: none; margin-left: -1.4em; }

/* 인라인 코드 */
.md-content code:not(pre code) {
  background: rgba(135, 131, 120, 0.15);
  color: #eb5757;
  padding: 2px 6px;
  border-radius: 4px;
  font-family: -apple-system-ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.88em;
}

/* 코드 블록 */
.md-content pre {
  background: #f7f6f3;
  border: 1px solid rgba(55,53,47,0.06);
  border-radius: 6px;
  padding: 14px 18px;
  overflow-x: auto;
  font-size: 13.5px; line-height: 1.5;
  margin: 0.6em 0 1em;
}
.md-content pre code {
  background: transparent;
  padding: 0;
  color: #37352f;
  font-family: -apple-system-ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 13.5px;
}

/* 인용구 */
.md-content blockquote {
  margin: 0.6em 0;
  padding: 0.2em 0 0.2em 1em;
  border-left: 3px solid #37352f;
  color: rgba(55,53,47,0.85);
}
.md-content blockquote > p { margin: 0.3em 0; }

/* 표 */
.md-content table {
  border-collapse: collapse;
  margin: 0.8em 0;
  font-size: 14px;
  width: auto; min-width: 60%;
  display: block; overflow-x: auto;
}
.md-content thead { background: rgba(55,53,47,0.04); }
.md-content th, .md-content td {
  border: 1px solid rgba(55,53,47,0.16);
  padding: 7px 11px;
  text-align: left;
}
.md-content th { font-weight: 600; }

/* 가로 구분선 */
.md-content hr {
  border: 0; border-top: 1px solid rgba(55,53,47,0.16);
  margin: 1.6em 0;
}

/* 이미지 */
.md-content img {
  max-width: 100%; height: auto;
  border-radius: 6px;
  margin: 0.4em 0;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

/* 키보드 키 */
.md-content kbd {
  background: #fafafa;
  border: 1px solid rgba(55,53,47,0.16);
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 1px 6px;
  font-family: -apple-system-ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 0.85em;
}

/* 모바일 — 패딩 축소 */
@media (max-width: 720px) {
  .md-content { padding: 28px 20px 60px; font-size: 15px; }
  .md-content h1 { font-size: 1.7em; }
  .md-content h2 { font-size: 1.35em; }
}

.text-wrap { flex: 1; background: #fff; overflow: auto; }
.text-content {
  margin: 0; padding: 18px 24px;
  font-family: -apple-system-ui-monospace, "SF Mono", Menlo, Monaco, Consolas, monospace;
  font-size: 12.5px; line-height: 1.55;
  color: var(--text);
  white-space: pre-wrap; word-break: break-word;
  background: #fff;
}

.unsupported-wrap {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 8px;
  color: #fff; padding: 40px 20px;
}

.zip-wrap {
  width: 100%; height: 100%;
  background: #fff;
  display: flex; flex-direction: column;
}
.zip-header {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 18px;
  background: #f6f6f8;
  border-bottom: 0.5px solid var(--border);
  font-size: 13px; font-weight: 500;
  flex-shrink: 0;
}
.zip-header .icon { width: 16px; height: 16px; }
.zip-breadcrumb {
  display: flex; align-items: center; gap: 4px;
  flex: 1; min-width: 0;
  font-size: 12px; color: var(--text-secondary);
  overflow: hidden;
}
.zip-breadcrumb .crumb {
  cursor: pointer;
  padding: 2px 6px; border-radius: 4px;
  white-space: nowrap;
}
.zip-breadcrumb .crumb:hover { background: rgba(0,0,0,0.05); color: var(--text); }
.zip-breadcrumb .crumb.current { color: var(--text); font-weight: 500; pointer-events: none; }
.zip-breadcrumb .crumb-sep { color: var(--muted); font-size: 10px; }

.zip-list-header {
  display: grid;
  grid-template-columns: 24px 1fr 100px 150px;
  gap: 0;
  padding: 0; background: #f0f0f2;
  border-bottom: 0.5px solid var(--border);
  font-size: 11px; color: var(--text-secondary); font-weight: 500;
  flex-shrink: 0;
}
.zip-list-header > div {
  padding: 5px 12px;
  border-right: 0.5px solid var(--separator);
}
.zip-list-header > div:last-child { border-right: none; }

.zip-list { flex: 1; overflow-y: auto; }
.zip-entry {
  display: grid;
  grid-template-columns: 24px 1fr 100px 150px;
  gap: 0; align-items: center;
  font-size: 13px;
  border-bottom: 0.5px solid var(--separator);
  color: var(--text);
  transition: background 0.05s;
}
.zip-entry:last-child { border-bottom: none; }
.zip-entry > div { padding: 4px 12px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.zip-entry.dir { cursor: pointer; }
.zip-entry.dir:hover { background: var(--row-hover); }
.zip-entry .icon-cell { padding: 0 0 0 12px !important; display: flex; align-items: center; }
.zip-entry .icon { width: 15px; height: 15px; }
.zip-entry.dir .name { color: var(--text); font-weight: 500; }
.zip-entry .muted { color: var(--muted); font-size: 12px; }
.zip-empty { padding: 40px 20px; text-align: center; color: var(--muted); }

.unsupported-title { font-size: 15px; font-weight: 500; margin-top: 8px; }

/* ==================== Modal ==================== */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.25);
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000; padding: 20px;
  opacity: 0; pointer-events: none;
  transition: opacity 0.15s ease;
}
.modal-backdrop.show { opacity: 1; pointer-events: auto; }
.modal {
  background: rgba(252, 252, 252, 0.98);
  backdrop-filter: saturate(180%) blur(40px);
  border: 0.5px solid var(--border-strong);
  border-radius: 11px;
  padding: 18px 22px 14px;
  width: 100%; max-width: 320px;
  transform: scale(0.97); transition: transform 0.15s ease;
  box-shadow: var(--shadow-window);
}
.modal-backdrop.show .modal { transform: scale(1); }
.modal-title {
  font-size: 13px; font-weight: 600; margin: 0 0 4px;
  display: flex; align-items: center; gap: 6px;
}
.modal-title .icon { width: 14px; height: 14px; color: var(--accent); }
.modal-title.danger { color: var(--danger); }
.modal-title.danger .icon { color: var(--danger); }
.modal-message { color: var(--text-secondary); font-size: 12px; margin: 0 0 12px; word-break: break-all; line-height: 1.5; }
.modal input[type=text] { margin-bottom: 12px; padding: 4px 9px; font-size: 13px; }
.modal-actions { display: flex; gap: 6px; justify-content: flex-end; }
.modal-actions .btn { min-width: 68px; justify-content: center; }

.modal-conflict { max-width: 520px; }
.modal-conflict .bulk-actions {
  display: flex; gap: 6px; margin-bottom: 12px; flex-wrap: wrap;
}
.modal-conflict .bulk-actions .btn { flex: 1; justify-content: center; min-width: 100px; }
.conflict-list {
  max-height: 280px; overflow-y: auto;
  border: 0.5px solid var(--border);
  border-radius: 6px;
  background: rgba(0,0,0,0.02);
  margin-bottom: 14px;
}
.conflict-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-bottom: 0.5px solid var(--separator);
  font-size: 12px;
}
.conflict-row:last-child { border-bottom: none; }
.conflict-row .cf-info { min-width: 0; }
.conflict-row .cf-name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conflict-row .cf-meta { color: var(--muted); font-size: 11px; }
.conflict-row .cf-policy {
  display: inline-flex; gap: 2px;
  background: rgba(0,0,0,0.05);
  border-radius: 5px; padding: 2px;
}
.conflict-row .cf-policy button {
  background: transparent; border: none; padding: 3px 9px;
  font-size: 11px; cursor: pointer; border-radius: 4px;
  color: var(--text-secondary);
  font-family: inherit;
}
.conflict-row .cf-policy button.active {
  background: #fff; color: var(--text);
  box-shadow: 0 0.5px 1px rgba(0,0,0,0.15);
  font-weight: 500;
}
.conflict-row .cf-policy button:hover:not(.active) { color: var(--text); }

/* ==================== Toast (popup) ==================== */
.toast {
  position: fixed; bottom: 40px; left: 50%;
  transform: translateX(-50%) translateY(30px) scale(0.95);
  background: rgba(40, 40, 42, 0.96);
  backdrop-filter: saturate(180%) blur(30px);
  border: 0.5px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  padding: 12px 20px;
  color: #fff; font-size: 13px; font-weight: 500; z-index: 1100;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.35), 0 2px 8px rgba(0, 0, 0, 0.2);
  opacity: 0;
  transition: opacity 0.25s cubic-bezier(0.2, 0.8, 0.2, 1),
              transform 0.25s cubic-bezier(0.2, 0.8, 0.2, 1);
  display: flex; align-items: center; gap: 10px;
  max-width: calc(100% - 40px);
  min-width: 200px;
  pointer-events: none;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }
.toast .icon { width: 18px; height: 18px; flex-shrink: 0; }
.toast.ok .icon { color: var(--ok); }
.toast.err .icon { color: var(--danger); }

/* 성공 토스트 둥근 체크 배경 */
.toast .toast-icon-wrap {
  width: 24px; height: 24px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.toast.ok .toast-icon-wrap { background: rgba(48, 209, 88, 0.2); }
.toast.err .toast-icon-wrap { background: rgba(255, 69, 58, 0.2); }
.toast.ok .toast-icon-wrap .icon,
.toast.err .toast-icon-wrap .icon { width: 14px; height: 14px; }

/* ==================== Mobile ==================== */
@media (max-width: 820px) {
  body { padding: 0; }
  .window {
    grid-template-columns: 1fr;
    grid-template-rows: 44px auto auto 1fr 26px;
    border-radius: 0;
    min-height: 100vh;
  }
  .titlebar { grid-column: 1; height: 44px; }
  .titlebar-nav { margin-left: 10px; }
  .traffic-lights { display: none; }
  .titlebar-title { font-size: 13px; }
  .sidebar { display: none; }
  .content { grid-row: 2 / 5; }
  .statusbar { grid-column: 1; }

  .list-header { display: none; }
  .file-row {
    display: grid;
    grid-template-columns: 32px 1fr auto;
    row-gap: 4px;
    padding: 8px 12px;
  }
  .file-row > div { padding: 2px 6px; }
  .file-row .actions-cell { grid-column: 1 / 4; text-align: right; }
  .file-row > div:nth-child(3)::before { content: "공개 "; color: var(--muted); font-size: 11px; }
  .file-row > div:nth-child(4)::before { content: "크기 "; color: var(--muted); font-size: 11px; }
  .file-row > div:nth-child(5)::before { content: "수정 "; color: var(--muted); font-size: 11px; }

  .login-window { width: 88%; padding: 28px 22px 20px; }
}
