/* === Base Reset & Variables === */
:root {
  --bg: #FAF8F4;
  --bg-surface: #F0EBE0;
  --bg-card: #E5DDD0;
  --bg-hover: #D4C9B0;
  --border: #D4C9B0;
  --text: #1A1A18;
  --text-muted: #6B6458;
  --text-bright: #1A1A18;
  --accent: #C8A96E;
  --accent-hover: #B8963E;
  --success: #5A8C5A;
  --danger: #C45B4F;
  --warning: #C8A96E;
  --font-mono: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
  --font-ui: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --radius: 8px;
  --radius-sm: 4px;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: var(--font-ui);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

/* === Auth Screen === */
.auth-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.auth-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px 36px;
  width: 100%;
  max-width: 400px;
  text-align: center;
}

.auth-logo {
  width: 100px;
  height: 100px;
  object-fit: contain;
  border-radius: 50%;
  margin-bottom: 16px;
}

.auth-card h2 {
  font-size: 24px;
  color: var(--accent);
  margin-bottom: 4px;
}

.auth-subtitle {
  color: var(--text-muted);
  font-size: 14px;
  margin-bottom: 24px;
}

.auth-error {
  background: rgba(196, 91, 79, 0.1);
  border: 1px solid var(--danger);
  color: var(--danger);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 16px;
  text-align: left;
}

#auth-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

#auth-form input {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  color: var(--text);
  font-size: 14px;
  width: 100%;
}

#auth-form input::placeholder {
  color: var(--text-muted);
}

#auth-form input:focus {
  outline: none;
  border-color: var(--accent);
}

.auth-submit {
  width: 100%;
  padding: 12px;
  font-size: 15px;
  margin-top: 4px;
}

.auth-toggle {
  margin-top: 20px;
  font-size: 13px;
  color: var(--text-muted);
}

.auth-toggle a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}

.auth-toggle a:hover {
  text-decoration: underline;
}

.auth-rat-link {
  margin-top: 12px;
  font-size: 12px;
}

.rat-prompt {
  color: var(--text);
  font-size: 15px;
  margin-bottom: 20px;
}

#rat-input {
  text-align: center;
}

/* === Header === */
header {
  padding: 20px 32px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 16px;
}

.header-logo {
  width: 64px;
  height: 64px;
  object-fit: contain;
  border-radius: 50%;
}

.btn-signout {
  margin-left: auto;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 12px;
}

.btn-signout:hover {
  color: var(--text);
  border-color: var(--text-muted);
}

.btn-about {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 12px;
}

.btn-about:hover {
  color: var(--text);
  border-color: var(--text-muted);
}

/* === About Page === */
.about-page {
  max-width: 700px;
  margin: 0 auto;
  padding: 40px 32px;
}

.about-content {
  display: flex;
  flex-direction: column;
  gap: 32px;
}

.about-hero {
  text-align: center;
}

.about-logo {
  width: 120px;
  height: 120px;
  object-fit: contain;
  border-radius: 50%;
  margin-bottom: 16px;
}

.about-hero h2 {
  font-size: 28px;
  color: var(--accent);
  margin-bottom: 4px;
}

.about-tagline {
  color: var(--text-muted);
  font-size: 16px;
}

.about-section h3 {
  font-size: 16px;
  color: var(--text-bright);
  margin-bottom: 10px;
}

.about-section p {
  color: var(--text);
  font-size: 14px;
  line-height: 1.7;
}

.about-steps {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.about-step {
  display: flex;
  gap: 14px;
  align-items: flex-start;
}

.about-step-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  min-width: 28px;
  border-radius: 50%;
  background: var(--accent);
  color: #FFFFFF;
  font-size: 13px;
  font-weight: 700;
  margin-top: 2px;
}

.about-step strong {
  color: var(--text-bright);
  font-size: 14px;
  display: block;
  margin-bottom: 4px;
}

.about-step p {
  color: var(--text);
  font-size: 13px;
  line-height: 1.6;
  margin: 0;
}

#btn-about-back {
  align-self: center;
}

header h1 {
  font-size: 20px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: -0.5px;
}

.subtitle {
  color: var(--text-muted);
  font-size: 14px;
}

/* === Main === */
main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 32px;
}

/* === Step Navigation === */
.steps {
  display: flex;
  gap: 4px;
  margin-bottom: 32px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 16px;
}

.step {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: 14px;
  opacity: 0.5;
  transition: opacity 0.2s;
}

.step.active {
  opacity: 1;
  color: var(--accent);
}

.step.completed {
  opacity: 0.8;
  color: var(--success);
}

.step-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid currentColor;
  font-size: 12px;
  font-weight: 600;
}

.step.active .step-num {
  background: var(--accent);
  color: #FFFFFF;
  border-color: var(--accent);
}

.step.completed .step-num {
  background: var(--success);
  color: #FFFFFF;
  border-color: var(--success);
}

/* === Step Content === */
.step-content {
  display: none;
}

.step-content.active {
  display: block;
}

.step-content h2 {
  font-size: 18px;
  margin-bottom: 8px;
  color: var(--text-bright);
}

.help-text {
  color: var(--text-muted);
  font-size: 14px;
  margin-bottom: 24px;
}

/* === Volumes Grid === */
.volumes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}

.volume-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}

.volume-card:hover {
  border-color: var(--accent);
  background: var(--bg-hover);
}

.volume-card .volume-name {
  font-weight: 600;
  font-size: 14px;
  color: var(--text-bright);
  margin-bottom: 4px;
}

.volume-card .volume-path {
  font-size: 12px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  word-break: break-all;
}

.volume-card .volume-type {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* === Selected Devices === */
.selected-devices {
  margin-bottom: 24px;
}

.selected-devices h3 {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 12px;
  font-weight: 500;
}

#device-cards {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.device-card {
  background: var(--bg-card);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.device-card .device-info {
  flex: 1;
}

.device-card .device-label {
  font-weight: 600;
  font-size: 14px;
  color: var(--accent);
}

.device-card .device-path {
  font-size: 12px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.device-card .btn-remove {
  background: none;
  border: none;
  color: var(--danger);
  cursor: pointer;
  font-size: 18px;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
}

.device-card .btn-remove:hover {
  background: rgba(196, 91, 79, 0.1);
}

/* === Buttons === */
.btn {
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, opacity 0.2s;
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  color: #FFFFFF;
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
}

.btn-secondary {
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--bg-hover);
}

.btn-danger {
  background: var(--danger);
  color: white;
}

.btn-danger:hover:not(:disabled) {
  opacity: 0.85;
}

.btn-small {
  padding: 4px 12px;
  font-size: 12px;
}

/* === Scan Progress === */
#scan-progress {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-top: 16px;
}

.scan-device-progress {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

.scan-device-progress .device-name {
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 4px;
  color: var(--text-bright);
}

.scan-device-progress .scan-status {
  font-size: 13px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.scan-device-progress .scan-count {
  font-size: 13px;
  color: var(--accent);
  margin-top: 4px;
}

.scan-device-progress.done .device-name {
  color: var(--success);
}

/* === Comparison View === */
.compare-header {
  margin-bottom: 16px;
}

.summary-bar {
  display: flex;
  gap: 20px;
  padding: 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin: 12px 0;
}

.summary-stat {
  text-align: center;
}

.summary-stat .stat-value {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-bright);
}

.summary-stat .stat-label {
  font-size: 12px;
  color: var(--text-muted);
}

.summary-stat.success .stat-value { color: var(--success); }
.summary-stat.warning .stat-value { color: var(--warning); }
.summary-stat.danger .stat-value { color: var(--danger); }

.compare-controls {
  display: flex;
  gap: 16px;
  margin: 12px 0;
  flex-wrap: wrap;
}

.compare-controls label,
.compare-actions label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-muted);
}

.compare-controls select,
.compare-actions select {
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  font-size: 13px;
}

.compare-actions {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 16px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 16px;
  flex-wrap: wrap;
}

/* === File Tree === */
.file-tree {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow-x: auto;
  margin-bottom: 16px;
}

.tree-header {
  background: var(--bg-surface);
  border-bottom: 2px solid var(--border);
  font-weight: 600;
  font-size: 12px;
  position: sticky;
  top: 0;
  z-index: 1;
}

.tree-node {
  border-bottom: 1px solid var(--border);
}

.tree-node:last-child {
  border-bottom: none;
}

.tree-row {
  display: flex;
  align-items: center;
  padding: 8px 12px;
  gap: 8px;
  cursor: pointer;
  transition: background 0.15s;
  font-size: 13px;
}

.tree-row:hover {
  background: var(--bg-hover);
}

.tree-row .indent {
  flex-shrink: 0;
}

.tree-row .toggle {
  width: 16px;
  text-align: center;
  color: var(--text-muted);
  flex-shrink: 0;
  font-size: 11px;
  user-select: none;
}

.tree-row .icon {
  flex-shrink: 0;
  font-size: 14px;
}

.tree-row .node-name {
  flex: 1;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-bright);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tree-row .dir-summary {
  font-size: 12px;
  color: var(--text-muted);
  margin-left: 8px;
  white-space: nowrap;
}

.tree-row .device-indicators {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.device-col-header {
  min-width: 100px;
  text-align: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  flex-shrink: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 0 4px;
}

.device-col {
  min-width: 100px;
  text-align: center;
  font-size: 12px;
  font-family: var(--font-mono);
  flex-shrink: 0;
  padding: 2px 4px;
  border-radius: var(--radius-sm);
}

.device-col.present {
  color: var(--success);
}

.device-col.missing {
  color: var(--danger);
  opacity: 0.6;
}

.device-dot {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  border: 2px solid transparent;
}

.device-dot.present {
  background: rgba(90, 140, 90, 0.15);
  border-color: var(--success);
  color: var(--success);
}

.device-dot.missing {
  background: rgba(196, 91, 79, 0.1);
  border-color: var(--danger);
  color: var(--danger);
}

.tree-row .checkbox {
  flex-shrink: 0;
}

.tree-row input[type="checkbox"] {
  accent-color: var(--accent);
  width: 16px;
  height: 16px;
  cursor: pointer;
}

.tree-children {
  display: none;
}

.tree-children.expanded {
  display: block;
}

/* === Progress Bars === */
.progress-section {
  margin-bottom: 24px;
}

.progress-info {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  margin-bottom: 6px;
  color: var(--text);
}

.progress-bar {
  height: 8px;
  background: var(--bg-surface);
  border-radius: 4px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 4px;
  transition: width 0.3s ease;
  width: 0%;
}

.progress-stats {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 6px;
}

.current-file-progress {
  margin-bottom: 24px;
  padding: 12px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

/* === Copy Log === */
.copy-log {
  max-height: 200px;
  overflow-y: auto;
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 12px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 16px;
}

.copy-log-entry {
  padding: 2px 0;
  color: var(--text-muted);
}

.copy-log-entry.success {
  color: var(--success);
}

.copy-log-entry.error {
  color: var(--danger);
}

.copy-result {
  padding: 20px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 16px;
  text-align: center;
}

.copy-result h3 {
  font-size: 18px;
  margin-bottom: 8px;
}

.copy-result.success h3 { color: var(--success); }
.copy-result.partial h3 { color: var(--warning); }
.copy-result.error h3 { color: var(--danger); }

.copy-actions {
  display: flex;
  gap: 12px;
}

/* === Add Device Bar === */
.add-device-bar {
  display: flex;
  gap: 12px;
  margin-bottom: 24px;
  align-items: center;
}

.add-device-bar input {
  flex: 1;
  max-width: 300px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  color: var(--text);
  font-size: 14px;
}

.add-device-bar input::placeholder {
  color: var(--text-muted);
}

.add-device-bar input:focus {
  outline: none;
  border-color: var(--accent);
}

/* === Mobile Overlay === */
.mobile-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(26, 26, 24, 0.5);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.mobile-overlay-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 36px 28px;
  text-align: center;
  max-width: 380px;
  width: 100%;
}

.mobile-overlay-img {
  width: 100px;
  height: 100px;
  object-fit: contain;
  border-radius: 50%;
  margin-bottom: 20px;
}

.mobile-overlay-card h3 {
  font-size: 18px;
  color: var(--text-bright);
  margin-bottom: 16px;
}

.mobile-overlay-card p {
  color: var(--text);
  font-size: 14px;
  line-height: 1.7;
  margin-bottom: 12px;
}

.mobile-overlay-card p:last-of-type {
  margin-bottom: 0;
}

.app-blurred {
  filter: blur(8px);
  pointer-events: none;
  user-select: none;
}

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

/* === Scrollbar === */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg);
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}
