/* ===== Win95 Design System ===== */
:root {
  --win-bg: #c0c0c0;
  --win-surface: #d4d0c8;
  --win-white: #ffffff;
  --win-border-light: #ffffff;
  --win-border-dark: #404040;
  --win-border-mid: #808080;
  --win-title-start: #00007b;
  --win-title-end: #1084d0;
  --win-text: #1a1a2e;
  --win-text-dim: #404040;
  --win-text-muted: #808080;
  --win-highlight: #00007b;
  --win-highlight-text: #ffffff;
  --win-folder: #ffd700;
  --win-folder-border: #b8960f;
  --accent-blue: #00007b;
  --accent-green: #2e8b2e;
  --accent-gold: #b8960f;
  --accent-red: #b22222;
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: 'IBM Plex Mono', monospace;
}

html, body {
  min-height: 100vh;
  background: #008080;
}

body {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px;
  padding-bottom: 32px;
}

/* ===== Window Chrome ===== */
.window {
  background: var(--win-bg);
  border-top: 2px solid var(--win-border-light);
  border-left: 2px solid var(--win-border-light);
  border-right: 2px solid var(--win-border-dark);
  border-bottom: 2px solid var(--win-border-dark);
  width: 100%;
  max-width: 940px;
  display: flex;
  flex-direction: column;
}

/* Title bar */
.title-bar {
  background: linear-gradient(90deg, var(--win-title-start), var(--win-title-end));
  color: #fff;
  padding: 3px 4px 3px 6px;
  display: flex;
  align-items: center;
  gap: 4px;
  user-select: none;
  flex-shrink: 0;
}

.title-icon {
  width: 16px;
  height: 16px;
  background: var(--win-bg);
  border: 1px solid var(--win-border-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 8px;
  font-weight: 600;
  color: var(--win-text);
  flex-shrink: 0;
  letter-spacing: -0.5px;
}

.title-text {
  flex: 1;
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
}

.title-buttons {
  display: flex;
  gap: 2px;
}

.title-btn {
  width: 16px;
  height: 14px;
  background: var(--win-bg);
  border-top: 1.5px solid var(--win-border-light);
  border-left: 1.5px solid var(--win-border-light);
  border-right: 1.5px solid var(--win-border-dark);
  border-bottom: 1.5px solid var(--win-border-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 8px;
  color: var(--win-text);
  cursor: default;
  line-height: 1;
}

/* Menu bar */
.menu-bar {
  background: var(--win-bg);
  padding: 1px 2px;
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--win-border-mid);
  flex-shrink: 0;
}

.menu-item {
  font-size: 12px;
  padding: 2px 8px;
  cursor: default;
  color: var(--win-text);
  white-space: nowrap;
}

.menu-item:hover {
  background: var(--win-highlight);
  color: var(--win-highlight-text);
}

/* Toolbar */
.toolbar {
  background: var(--win-bg);
  padding: 2px 4px;
  display: flex;
  align-items: center;
  gap: 2px;
  border-bottom: 1px solid var(--win-border-dark);
  flex-shrink: 0;
  flex-wrap: wrap;
}

.tool-btn {
  background: var(--win-bg);
  border-top: 1.5px solid var(--win-border-light);
  border-left: 1.5px solid var(--win-border-light);
  border-right: 1.5px solid var(--win-border-dark);
  border-bottom: 1.5px solid var(--win-border-dark);
  padding: 3px 8px;
  font-size: 11px;
  font-family: 'IBM Plex Mono', monospace;
  color: var(--win-text);
  cursor: default;
  display: flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
  line-height: 1.2;
}

.tool-btn:active:not(:disabled),
.tool-btn.active {
  border-top: 1.5px solid var(--win-border-dark);
  border-left: 1.5px solid var(--win-border-dark);
  border-right: 1.5px solid var(--win-border-light);
  border-bottom: 1.5px solid var(--win-border-light);
  background: #a0a0a0;
}

.tool-btn:disabled {
  color: var(--win-text-muted);
  cursor: default;
}

.tool-sep {
  width: 1px;
  height: 20px;
  background: var(--win-border-dark);
  margin: 0 2px;
  box-shadow: 1px 0 0 var(--win-border-light);
  flex-shrink: 0;
}

/* Window body */
.window-body {
  padding: 6px;
  flex: 1;
}

/* Tab content */
.tab-content {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* ===== Drop Zone ===== */
.drop-zone {
  background: var(--win-white);
  border-top: 1px solid var(--win-border-dark);
  border-left: 1px solid var(--win-border-dark);
  border-right: 1px solid var(--win-border-light);
  border-bottom: 1px solid var(--win-border-light);
  min-height: 180px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: default;
}

.drop-zone.drag-over {
  outline: 2px dashed var(--win-highlight);
  outline-offset: -4px;
  background: #f0f0ff;
}

.drop-zone-inner {
  border: 2px dashed var(--win-border-mid);
  padding: 20px 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  text-align: center;
  margin: 8px;
  width: calc(100% - 16px);
}

.drop-zone-text {
  font-size: 12px;
  color: var(--win-text-dim);
  font-weight: 500;
}

.drop-zone-sub {
  font-size: 11px;
  color: var(--win-text-muted);
}

.format-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  justify-content: center;
  margin-top: 2px;
}

.local-badge {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 10px;
  color: var(--accent-green);
  margin-top: 6px;
  font-weight: 500;
}

.format-tag {
  background: var(--win-bg);
  border-top: 1.5px solid var(--win-border-light);
  border-left: 1.5px solid var(--win-border-light);
  border-right: 1.5px solid var(--win-border-dark);
  border-bottom: 1.5px solid var(--win-border-dark);
  padding: 1px 5px;
  font-size: 10px;
  font-weight: 400;
  color: var(--win-text);
}

/* ===== Stats Row ===== */
.stats-row {
  display: flex;
  gap: 6px;
}

.stat-box {
  flex: 1;
  background: var(--win-white);
  border-top: 1px solid var(--win-border-dark);
  border-left: 1px solid var(--win-border-dark);
  border-right: 1px solid var(--win-border-light);
  border-bottom: 1px solid var(--win-border-light);
  padding: 6px 8px;
  text-align: center;
}

.stat-label {
  font-size: 10px;
  color: var(--win-text-muted);
  font-weight: 400;
  letter-spacing: 0.5px;
}

.stat-value {
  font-size: 15px;
  font-weight: 600;
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stat-value.blue  { color: var(--accent-blue); }
.stat-value.green { color: var(--accent-green); }
.stat-value.gold  { color: var(--accent-gold); }
.stat-value.red   { color: var(--accent-red); }

/* ===== File List ===== */
.file-list-container {
  background: var(--win-white);
  border-top: 1px solid var(--win-border-dark);
  border-left: 1px solid var(--win-border-dark);
  border-right: 1px solid var(--win-border-light);
  border-bottom: 1px solid var(--win-border-light);
  overflow: auto;
  max-height: 340px;
}

.fl-header {
  display: grid;
  grid-template-columns: 22px minmax(0,1fr) 72px 92px 56px;
  background: var(--win-bg);
  border-bottom: 1px solid var(--win-border-mid);
  position: sticky;
  top: 0;
  z-index: 1;
}

.fl-header > div {
  padding: 3px 6px;
  font-size: 11px;
  font-weight: 600;
  color: var(--win-text);
  border-right: 1px solid var(--win-border-mid);
  white-space: nowrap;
  overflow: hidden;
}

.fl-row {
  display: grid;
  grid-template-columns: 22px minmax(0,1fr) 72px 92px 56px;
  border-bottom: 1px solid #c8c8c8;
  cursor: default;
}

.fl-row:hover { background: #e8e8e8; }

.fl-row.selected {
  background: var(--win-highlight);
  color: var(--win-highlight-text);
}

.fl-row.selected .dl-btn {
  color: var(--win-highlight-text);
  border-color: rgba(255,255,255,0.5);
}

.fl-row > div {
  padding: 3px 6px;
  font-size: 11px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: flex;
  align-items: center;
}

.fl-row.dir-row { font-weight: 500; }

/* File icons */
.file-icon {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

/* ===== Preview Panel ===== */
.preview-panel {
  background: var(--win-white);
  border-top: 1px solid var(--win-border-dark);
  border-left: 1px solid var(--win-border-dark);
  border-right: 1px solid var(--win-border-light);
  border-bottom: 1px solid var(--win-border-light);
  display: flex;
  flex-direction: column;
  min-height: 200px;
  overflow: hidden;
}

.preview-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 3px 6px;
  border-bottom: 1px solid var(--win-border-mid);
  background: var(--win-bg);
  flex-shrink: 0;
}

.preview-filename {
  font-size: 11px;
  font-weight: 600;
  color: var(--win-text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  margin-right: 4px;
}

.preview-content {
  overflow: auto;
  flex: 1;
  padding: 6px;
}

.preview-content pre {
  font-size: 11px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-all;
  font-family: 'IBM Plex Mono', monospace;
}

.preview-content pre code {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
}

.preview-content img {
  max-width: 100%;
  object-fit: contain;
  display: block;
}

.media-preview {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px 0;
}

.media-preview audio {
  width: 100%;
}

.media-preview video {
  max-width: 100%;
  max-height: 420px;
}

.preview-hint {
  color: var(--win-text-muted);
  font-size: 11px;
  padding: 8px 2px;
}

/* ===== Progress Bar ===== */
.progress-container { margin: 0; }

.progress-label {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--win-text);
  margin-bottom: 3px;
}

.progress-track {
  height: 16px;
  background: var(--win-white);
  border-top: 1px solid var(--win-border-dark);
  border-left: 1px solid var(--win-border-dark);
  border-right: 1px solid var(--win-border-light);
  border-bottom: 1px solid var(--win-border-light);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: repeating-linear-gradient(
    90deg,
    #00007b 0px,
    #00007b 8px,
    #0000a0 8px,
    #0000a0 10px
  );
  transition: width 0.08s linear;
}

/* ===== Form Controls ===== */
select, input[type="text"], input[type="password"] {
  background: var(--win-white);
  border-top: 1px solid var(--win-border-dark);
  border-left: 1px solid var(--win-border-dark);
  border-right: 1px solid var(--win-border-light);
  border-bottom: 1px solid var(--win-border-light);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
  padding: 3px 6px;
  color: var(--win-text);
  outline: none;
  border-radius: 0;
}

input[type="range"] {
  width: 80px;
  vertical-align: middle;
}

/* ===== Download Button ===== */
.dl-btn {
  background: var(--win-bg);
  border-top: 1px solid var(--win-border-light);
  border-left: 1px solid var(--win-border-light);
  border-right: 1px solid var(--win-border-dark);
  border-bottom: 1px solid var(--win-border-dark);
  padding: 1px 5px;
  font-size: 10px;
  font-family: 'IBM Plex Mono', monospace;
  cursor: default;
  color: var(--win-text);
  white-space: nowrap;
}

.dl-btn:active {
  border-top: 1px solid var(--win-border-dark);
  border-left: 1px solid var(--win-border-dark);
  border-right: 1px solid var(--win-border-light);
  border-bottom: 1px solid var(--win-border-light);
}

/* ===== Messages ===== */
.msg-box {
  padding: 5px 8px;
  font-size: 11px;
  border-top: 1px solid var(--win-border-dark);
  border-left: 1px solid var(--win-border-dark);
  border-right: 1px solid var(--win-border-light);
  border-bottom: 1px solid var(--win-border-light);
  line-height: 1.4;
}

.msg-box.error   { background: #fff0f0; color: var(--accent-red); }
.msg-box.warning { background: #fffbf0; color: var(--accent-gold); }
.msg-box.info    { background: var(--win-white); color: var(--win-text); }

/* ===== Status Bar ===== */
.status-bar {
  display: flex;
  border-top: 1px solid var(--win-border-mid);
  flex-shrink: 0;
}

.status-section {
  padding: 2px 8px;
  font-size: 11px;
  color: var(--win-text);
  border-top: 1px solid var(--win-border-dark);
  border-left: 1px solid var(--win-border-dark);
  border-right: 1px solid var(--win-border-light);
  border-bottom: 1px solid var(--win-border-light);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin: 2px 2px 2px 0;
}

.status-section:first-child { width: 14px; padding: 2px 0; }
.status-section.main        { flex: 1; }
.status-section.count       { min-width: 90px; }
.status-section.privacy     { min-width: 220px; }

/* ===== Create Mode ===== */
.create-options {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 4px 0;
}

.opt-group {
  display: flex;
  align-items: center;
  gap: 4px;
}

.opt-label {
  font-size: 11px;
  color: var(--win-text-dim);
  white-space: nowrap;
}

.create-fl {
  background: var(--win-white);
  border-top: 1px solid var(--win-border-dark);
  border-left: 1px solid var(--win-border-dark);
  border-right: 1px solid var(--win-border-light);
  border-bottom: 1px solid var(--win-border-light);
  overflow-y: auto;
  max-height: 180px;
}

.cfl-header {
  display: grid;
  grid-template-columns: minmax(0,1fr) 80px 28px;
  background: var(--win-bg);
  border-bottom: 1px solid var(--win-border-mid);
  padding: 3px 6px;
  position: sticky;
  top: 0;
}

.cfl-header > div {
  font-size: 11px;
  font-weight: 600;
}

.cfl-row {
  display: grid;
  grid-template-columns: minmax(0,1fr) 80px 28px;
  border-bottom: 1px solid #c8c8c8;
  padding: 3px 6px;
  align-items: center;
}

.cfl-row:hover { background: #e8e8e8; }

.cfl-row > div {
  font-size: 11px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.remove-btn {
  background: none;
  border: none;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  color: var(--accent-red);
  cursor: default;
  padding: 0 2px;
  line-height: 1;
}

.remove-btn:hover { text-decoration: underline; }

/* ===== Modal ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}

.modal {
  background: var(--win-bg);
  border-top: 2px solid var(--win-border-light);
  border-left: 2px solid var(--win-border-light);
  border-right: 2px solid var(--win-border-dark);
  border-bottom: 2px solid var(--win-border-dark);
  width: 320px;
}

.modal-title-bar {
  background: linear-gradient(90deg, var(--win-title-start), var(--win-title-end));
  color: #fff;
  padding: 3px 6px;
  font-size: 12px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 4px;
}

.modal-body {
  padding: 14px 12px 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.modal-text {
  font-size: 12px;
  color: var(--win-text);
  line-height: 1.5;
}

.modal-buttons {
  display: flex;
  gap: 4px;
  justify-content: flex-end;
}

/* ===== Layout ===== */
.main-area {
  display: flex;
  gap: 6px;
  min-height: 0;
}

.file-tree-panel {
  flex: 0 0 56%;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.file-preview-panel {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

/* ===== Fullscreen preview overlay ===== */
.fs-overlay {
  position: fixed;
  inset: 0;
  background: var(--win-bg);
  z-index: 300;
  display: flex;
  flex-direction: column;
}

.fs-overlay .preview-toolbar {
  flex-shrink: 0;
  background: var(--win-bg);
  padding: 3px 6px;
  border-bottom: 1px solid var(--win-border-mid);
}

.fs-overlay .preview-content {
  flex: 1;
  overflow: auto;
  padding: 12px;
  background: var(--win-white);
}

/* ===== Code with line numbers ===== */
.code-view {
  display: table;
  width: 100%;
  font-size: 11px;
  font-family: 'IBM Plex Mono', monospace;
  line-height: 1.6;
}

.line-nums {
  display: table-cell;
  text-align: right;
  padding: 0 10px 0 4px;
  border-right: 1px solid #e0e0e0;
  vertical-align: top;
  white-space: pre;
  user-select: none;
  color: var(--win-text-muted);
  width: 1px;
  font-size: 11px;
  font-family: 'IBM Plex Mono', monospace;
  line-height: 1.6;
}

.code-col {
  display: table-cell;
  padding-left: 10px;
  vertical-align: top;
  width: 100%;
}

.code-col pre {
  margin: 0;
  overflow-x: auto;
}

.code-col pre code.hljs {
  padding: 0;
  background: transparent;
}

.code-view.wrap-on .code-col pre,
.code-view.wrap-on .code-col pre code {
  white-space: pre-wrap;
  word-break: break-all;
  overflow-x: visible;
}

/* ===== App header (above window) ===== */
.app-header {
  width: 100%;
  max-width: 940px;
  background: var(--win-bg);
  border-top: 2px solid var(--win-border-light);
  border-left: 2px solid var(--win-border-light);
  border-right: 2px solid var(--win-border-dark);
  border-bottom: 2px solid var(--win-border-dark);
  padding: 10px 14px;
  margin-bottom: 6px;
  display: flex;
  align-items: baseline;
  gap: 14px;
}

.app-header-title {
  font-size: 20px;
  font-weight: 600;
  color: var(--accent-blue);
  white-space: nowrap;
  letter-spacing: -0.5px;
}

.app-header-desc {
  font-size: 11px;
  color: var(--win-text-muted);
  font-weight: 400;
}

/* ===== Utility ===== */
.hidden { display: none !important; }

/* ===== Responsive ===== */
@media (max-width: 620px) {
  body { padding: 4px; padding-bottom: 16px; }

  .main-area { flex-direction: column; }
  .file-tree-panel, .file-preview-panel { flex: none; width: 100%; }

  .fl-header,
  .fl-row {
    grid-template-columns: 22px minmax(0,1fr) 72px 56px;
  }

  .fl-header > div:nth-child(4),
  .fl-row > div:nth-child(4) { display: none; }

  .stats-row { flex-wrap: wrap; }
  .stat-box { flex: 0 0 calc(50% - 3px); }

  .tool-btn .btn-text { display: none; }

  .status-section.privacy { display: none; }
}
