/* ==========================================================================
   File Vault Studio - Design System
   与仓库既有暗色科技风同族（QR Matrix Studio token 体系），
   主色改为保险舱祖母绿，签名元素为「密文流」动效背景。
   ========================================================================== */

:root {
  /* Color Tokens - Dark Mode (Default) */
  --bg-app: #0b0f19;
  --bg-surface: #111827;
  --bg-card: #1e293b;
  --bg-card-hover: #243248;
  --bg-input: #0f172a;
  --border-color: #334155;
  --border-focus: #10b981;

  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;

  --color-primary: #10b981;
  --color-primary-hover: #059669;
  --color-primary-bg: rgba(16, 185, 129, 0.12);

  --color-accent: #6366f1;
  --color-secondary: #8b5cf6;
  --color-danger: #ef4444;
  --color-warning: #f59e0b;

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.25);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.35), 0 2px 4px -2px rgba(0, 0, 0, 0.25);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.45), 0 4px 6px -4px rgba(0, 0, 0, 0.35);
  --shadow-glow: 0 0 20px rgba(16, 185, 129, 0.22);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;
  --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

body.theme-light {
  --bg-app: #f1f5f9;
  --bg-surface: #ffffff;
  --bg-card: #ffffff;
  --bg-card-hover: #f8fafc;
  --bg-input: #f8fafc;
  --border-color: #cbd5e1;
  --border-focus: #059669;

  --text-main: #0f172a;
  --text-muted: #475569;
  --text-dim: #64748b;

  --color-primary: #059669;
  --color-primary-hover: #047857;
  --color-primary-bg: rgba(5, 150, 105, 0.08);

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08);
  --shadow-glow: 0 0 15px rgba(5, 150, 105, 0.15);
}

/* Reset & Base */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background-color: var(--bg-app);
  color: var(--text-main);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color 0.25s ease, color 0.25s ease;
}

button { font-family: inherit; }

:focus-visible {
  outline: 2px solid var(--border-focus);
  outline-offset: 2px;
}

/* Utilities */
.hidden { display: none !important; }
.w-full { width: 100%; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 0.75rem; }
.font-mono { font-family: var(--font-mono); }

/* Layout */
.app-layout {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Header */
.app-header {
  padding: 18px 24px 0;
}
.header-content {
  max-width: 1280px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.brand-area {
  display: flex;
  align-items: center;
  gap: 14px;
}
.brand-logo {
  width: 46px;
  height: 46px;
  flex-shrink: 0;
  filter: drop-shadow(0 0 10px rgba(16, 185, 129, 0.35));
}
.brand-icon { width: 100%; height: 100%; }
.brand-title {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: 0.3px;
  background: linear-gradient(90deg, var(--color-primary), var(--color-accent));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.brand-subtitle {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 2px;
}
.icon-btn {
  width: 42px;
  height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition);
}
.icon-btn:hover {
  color: var(--color-primary);
  border-color: var(--color-primary);
}
body.theme-dark .icon-sun { display: none; }
body.theme-light .icon-moon { display: none; }

/* Tabs */
.tab-bar {
  max-width: 1280px;
  margin: 16px auto 0;
  padding: 0 24px;
  width: 100%;
  display: flex;
  gap: 8px;
}
.tab-btn {
  padding: 10px 22px;
  min-height: 44px;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text-muted);
  background: transparent;
  border: 1px solid transparent;
  border-bottom: 2px solid transparent;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  cursor: pointer;
  transition: var(--transition);
}
.tab-btn:hover { color: var(--text-main); }
.tab-btn.active {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
  background: linear-gradient(180deg, transparent, var(--color-primary-bg));
}

/* Main grid */
.app-main {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 24px 32px;
  width: 100%;
  flex: 1;
}
.tab-panel {
  display: none;
  grid-template-columns: 330px 1fr;
  gap: 20px;
  align-items: start;
}
.tab-panel.active { display: grid; }

.side-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
  position: sticky;
  top: 16px;
}
.work-area {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

/* Cards */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 18px;
  box-shadow: var(--shadow-sm);
}
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.card-title {
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.3px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.card-title::before {
  content: "";
  width: 3px;
  height: 14px;
  border-radius: 2px;
  background: var(--color-primary);
}
.count-badge {
  font-size: 0.75rem;
  color: var(--text-muted);
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: 999px;
  padding: 2px 10px;
}

/* Fields */
.field-label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  margin: 10px 0 6px;
}
.input, .textarea, select.input {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-main);
  padding: 10px 12px;
  font-size: 0.88rem;
  min-height: 44px;
  transition: var(--transition);
}
.textarea {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  resize: vertical;
  min-height: 96px;
}
.input:focus, .textarea:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--color-primary-bg);
}
.input-row {
  display: flex;
  gap: 8px;
}
.input-row .input { flex: 1; }
.hint {
  font-size: 0.75rem;
  color: var(--text-dim);
  margin-top: 10px;
  line-height: 1.55;
}
.divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 16px 0 4px;
  color: var(--text-dim);
  font-size: 0.75rem;
}
.divider::before, .divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border-color);
}

/* File select label */
.file-select {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-input);
  border: 1px dashed var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px;
  min-height: 44px;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 0.84rem;
  transition: var(--transition);
}
.file-select:hover {
  border-color: var(--color-primary);
  color: var(--text-main);
}

/* Key badge */
.key-badge {
  margin-top: 12px;
  font-size: 0.76rem;
  padding: 8px 12px;
  border-radius: var(--radius-md);
  border: 1px solid;
  word-break: break-all;
}
.key-badge.not-ready {
  color: var(--color-warning);
  border-color: rgba(245, 158, 11, 0.35);
  background: rgba(245, 158, 11, 0.08);
}
.key-badge.ready {
  color: var(--color-primary);
  border-color: rgba(16, 185, 129, 0.35);
  background: var(--color-primary-bg);
}

/* Segmented control */
.seg-group {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 4px;
  margin-top: 4px;
}
.seg-btn {
  padding: 9px 6px;
  min-height: 40px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
}
.seg-btn:hover { color: var(--text-main); }
.seg-btn.active {
  background: var(--color-primary-bg);
  color: var(--color-primary);
  box-shadow: inset 0 0 0 1px rgba(16, 185, 129, 0.4);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  min-height: 44px;
  font-size: 0.88rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}
.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.btn-lg { padding: 13px 20px; font-size: 0.95rem; }
.btn-sm { min-height: 36px; padding: 6px 12px; font-size: 0.8rem; }
.btn-primary {
  background: var(--color-primary);
  color: #06251a;
}
.btn-primary:hover:not(:disabled) {
  background: var(--color-primary-hover);
  box-shadow: var(--shadow-glow);
}
.btn-secondary {
  background: var(--color-primary-bg);
  color: var(--color-primary);
  border-color: rgba(16, 185, 129, 0.35);
}
.btn-secondary:hover:not(:disabled) {
  background: rgba(16, 185, 129, 0.2);
}
.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border-color: var(--border-color);
}
.btn-ghost:hover:not(:disabled) {
  color: var(--text-main);
  border-color: var(--text-dim);
  background: var(--bg-card-hover);
}
.btn-icon {
  width: 40px;
  min-height: 40px;
  padding: 0;
}
.btn-danger:hover:not(:disabled) {
  color: var(--color-danger);
  border-color: var(--color-danger);
}

/* Dropzone & cipher stream signature */
.dropzone {
  position: relative;
  border: 2px dashed var(--border-color);
  border-radius: var(--radius-xl);
  background: var(--bg-surface);
  min-height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  overflow: hidden;
  transition: var(--transition);
}
.dropzone:hover, .dropzone.drag-over {
  border-color: var(--color-primary);
  background: var(--color-primary-bg);
  box-shadow: var(--shadow-glow);
}
.dropzone:focus-visible {
  outline: 2px solid var(--border-focus);
  outline-offset: 2px;
}
.cipher-stream {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}
.cipher-stream-lines {
  position: absolute;
  top: 50%;
  left: 0;
  transform: translateY(-50%);
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.9;
  white-space: pre;
  color: var(--text-dim);
  opacity: 0.16;
  width: max-content;
  animation: cipher-drift 90s linear infinite;
}
.cipher-stream-lines.active {
  color: var(--color-primary);
  opacity: 0.34;
  animation-duration: 14s;
}
@keyframes cipher-drift {
  from { transform: translate(0, -50%); }
  to { transform: translate(-50%, -50%); }
}
.dropzone-inner {
  position: relative;
  z-index: 1;
  text-align: center;
  padding: 28px 20px;
}
.dz-icon { color: var(--text-dim); transition: var(--transition); }
.dropzone:hover .dz-icon, .dropzone.drag-over .dz-icon { color: var(--color-primary); }
.dz-title {
  margin-top: 10px;
  font-size: 0.95rem;
  font-weight: 600;
}
.dz-sub {
  margin-top: 4px;
  font-size: 0.78rem;
  color: var(--text-muted);
}
.dz-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: -4px;
}

/* File list */
.list-card { padding-bottom: 10px; }
.file-list {
  list-style: none;
  display: flex;
  flex-direction: column;
}
.file-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 6px;
  border-bottom: 1px solid var(--border-color);
  flex-wrap: wrap;
  transition: var(--transition);
}
.file-row:last-child { border-bottom: none; }
.file-row:hover { background: var(--bg-card-hover); }
.entry-row { padding-left: 26px; }
.file-icon {
  display: inline-flex;
  color: var(--text-dim);
  flex-shrink: 0;
}
.file-icon.locked { color: var(--color-warning); }
.file-icon.unlocked { color: var(--color-primary); }
.file-info {
  flex: 1;
  min-width: 160px;
  overflow: hidden;
}
.file-name {
  font-size: 0.88rem;
  font-weight: 600;
  overflow-wrap: anywhere;
}
.file-name.previewable {
  cursor: pointer;
  color: var(--color-primary);
}
.file-name.previewable:hover { text-decoration: underline; }
.file-meta {
  font-size: 0.74rem;
  color: var(--text-dim);
  font-family: var(--font-mono);
  margin-top: 2px;
  overflow-wrap: anywhere;
}
.zip-progress-text { color: var(--color-primary); }
.status-badge {
  flex-shrink: 0;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid;
}
.status-ready { color: var(--text-muted); border-color: var(--border-color); }
.status-working { color: var(--color-warning); border-color: rgba(245, 158, 11, 0.4); }
.status-done { color: var(--color-primary); border-color: rgba(16, 185, 129, 0.4); }
.status-error { color: var(--color-danger); border-color: rgba(239, 68, 68, 0.4); }
.error-text {
  flex-basis: 100%;
  font-size: 0.76rem;
  color: var(--color-danger);
}
.file-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}
.inline-progress { flex-basis: 100%; }

/* Progress bar */
.progress {
  height: 6px;
  border-radius: 999px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--color-primary), var(--color-accent));
  transition: width 0.25s ease;
  width: 0;
}
.progress.indeterminate .progress-fill {
  width: 34%;
  animation: indeterminate 1.2s ease-in-out infinite;
}
@keyframes indeterminate {
  0% { margin-left: -34%; }
  100% { margin-left: 100%; }
}

/* Empty state */
.empty-state {
  padding: 26px 12px;
  text-align: center;
  color: var(--text-dim);
  font-size: 0.84rem;
}

/* Output rows */
.output-row { background: var(--color-primary-bg); border-radius: var(--radius-md); }
.zip-parent-row { background: var(--bg-input); border-radius: var(--radius-md); }

/* Toast */
.toast-container {
  position: fixed;
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  width: min(92vw, 480px);
  pointer-events: none;
}
.toast {
  padding: 11px 18px;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  border: 1px solid;
  background: var(--bg-card);
  color: var(--text-main);
  animation: toast-in 0.25s ease;
  max-width: 100%;
}
@keyframes toast-in {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}
.toast-success { border-color: var(--color-primary); color: var(--color-primary); }
.toast-error { border-color: var(--color-danger); color: var(--color-danger); }
.toast-info { border-color: var(--border-focus); }
.toast-warning { border-color: var(--color-warning); color: var(--color-warning); }

/* Footer */
.app-footer {
  text-align: center;
  padding: 18px;
  font-size: 0.75rem;
  color: var(--text-dim);
  border-top: 1px solid var(--border-color);
}

/* ==========================================================================
   Responsive: tablet (768-1024) & mobile (<768)
   ========================================================================== */
@media (max-width: 1024px) {
  .tab-panel {
    grid-template-columns: 1fr;
  }
  .side-panel {
    position: static;
    flex-direction: row;
    flex-wrap: wrap;
  }
  .side-panel .card { flex: 1 1 300px; }
}

@media (max-width: 768px) {
  .app-header { padding: 14px 16px 0; }
  .tab-bar, .app-main { padding-left: 16px; padding-right: 16px; }
  .brand-subtitle { display: none; }
  .tab-btn { flex: 1; padding: 10px 8px; }
  .side-panel { flex-direction: column; }
  .side-panel .card { flex: 1 1 auto; }
  .dropzone { min-height: 160px; }
  .file-row { gap: 8px; }
  .file-actions { flex-basis: 100%; justify-content: flex-end; }
  .dz-actions { flex-wrap: wrap; }
}

@media (max-width: 480px) {
  .brand-title { font-size: 1.1rem; }
  .card { padding: 14px; }
  .btn-icon { width: 44px; }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .cipher-stream-lines { animation: none; }
  .progress.indeterminate .progress-fill { animation-duration: 2.4s; }
  .toast { animation: none; }
  * { transition-duration: 0.01ms !important; }
}
