:root {
  --cream: #FAF7F2;
  --cream-2: #F4EFE6;
  --surface: #FFFFFF;
  --ink: #1A2E26;
  --ink-soft: #5A6B63;
  --forest: #1F4D3F;
  --forest-deep: #143329;
  --caramel: #C4956C;
  --border: #E5DFD5;
  --border-strong: #D4CCBC;
  --success: #4A7C59;
  --error: #B85450;
  --shadow: 0 1px 2px rgba(20, 51, 41, 0.04), 0 8px 24px rgba(20, 51, 41, 0.06);
  --shadow-lg: 0 4px 12px rgba(20, 51, 41, 0.08), 0 24px 48px rgba(20, 51, 41, 0.10);
}

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

body {
  font-family: 'Manrope', sans-serif;
  background: var(--cream);
  color: var(--ink);
  min-height: 100vh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  background-image:
    radial-gradient(circle at 12% 18%, rgba(31, 77, 63, 0.04) 0%, transparent 40%),
    radial-gradient(circle at 88% 78%, rgba(196, 149, 108, 0.05) 0%, transparent 45%);
}

.layout {
  max-width: 1240px;
  margin: 0 auto;
  padding: 32px 32px 64px;
}

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 28px;
  margin-bottom: 36px;
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 14px; }
.brand-mark {
  width: 42px; height: 42px;
  background: var(--forest);
  border-radius: 12px;
  display: grid; place-items: center;
  color: var(--cream);
  font-family: 'Fraunces', serif;
  font-size: 22px; font-weight: 600;
  font-style: italic;
}
.brand-text h1 {
  font-family: 'Fraunces', serif;
  font-size: 22px;
  font-weight: 500;
  letter-spacing: -0.01em;
}
.brand-text p {
  font-size: 12px;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  margin-top: 2px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 100px;
  font-size: 13px;
  font-weight: 500;
}
.status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--ink-soft);
  box-shadow: 0 0 0 0 rgba(74, 124, 89, 0.4);
}
.status-dot.ready {
  background: var(--success);
  animation: pulse 2s infinite;
}
.status-dot.connected {
  background: var(--caramel);
  animation: pulse 1.4s infinite;
}
.status-dot.error { background: var(--error); }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(74, 124, 89, 0.5); }
  70% { box-shadow: 0 0 0 8px rgba(74, 124, 89, 0); }
  100% { box-shadow: 0 0 0 0 rgba(74, 124, 89, 0); }
}

.grid {
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  gap: 24px;
}
@media (max-width: 900px) {
  .grid { grid-template-columns: 1fr; }
  .layout { padding: 20px; }
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 28px;
  box-shadow: var(--shadow);
}
.card-title {
  font-family: 'Fraunces', serif;
  font-size: 20px;
  font-weight: 500;
  margin-bottom: 6px;
  letter-spacing: -0.01em;
}
.card-subtitle {
  color: var(--ink-soft);
  font-size: 14px;
  margin-bottom: 22px;
}

.step {
  display: flex;
  gap: 14px;
  padding: 16px;
  border-radius: 14px;
  background: var(--cream-2);
  margin-bottom: 12px;
  border: 1px solid transparent;
  transition: all 0.2s;
}
.step.done { background: rgba(74, 124, 89, 0.07); border-color: rgba(74, 124, 89, 0.2); }
.step-num {
  flex-shrink: 0;
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  display: grid; place-items: center;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-soft);
}
.step.done .step-num {
  background: var(--success);
  border-color: var(--success);
  color: white;
}
.step-content { flex: 1; }
.step-content h3 { font-size: 14px; font-weight: 600; margin-bottom: 4px; }
.step-content p { font-size: 13px; color: var(--ink-soft); }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  border: none;
  border-radius: 10px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-primary {
  background: var(--forest);
  color: var(--cream);
}
.btn-primary:hover { background: var(--forest-deep); transform: translateY(-1px); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn-ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--border-strong);
}
.btn-ghost:hover { background: var(--cream-2); }

.folder-display {
  margin-top: 12px;
  padding: 10px 14px;
  background: var(--cream-2);
  border-radius: 10px;
  font-size: 13px;
  font-family: 'Manrope', monospace;
  color: var(--forest);
  display: none;
}
.folder-display.shown { display: block; }

.qr-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}
.qr-frame {
  background: white;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
  margin-bottom: 18px;
  position: relative;
}
.qr-frame::before, .qr-frame::after {
  content: '';
  position: absolute;
  width: 18px; height: 18px;
  border: 2px solid var(--forest);
}
.qr-frame::before {
  top: -2px; left: -2px;
  border-right: none; border-bottom: none;
  border-top-left-radius: 8px;
}
.qr-frame::after {
  bottom: -2px; right: -2px;
  border-left: none; border-top: none;
  border-bottom-right-radius: 8px;
}
#qrcode canvas, #qrcode img { display: block; }

.url-display {
  width: 100%;
  padding: 12px;
  background: var(--cream-2);
  border-radius: 10px;
  font-size: 12px;
  font-family: monospace;
  color: var(--ink-soft);
  word-break: break-all;
  text-align: center;
  margin-bottom: 12px;
}

.config-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 10px;
}
.config-row label {
  font-size: 12px;
  color: var(--ink-soft);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.config-input {
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  font-family: inherit;
  font-size: 13px;
  background: var(--surface);
}
.config-input:focus { outline: 2px solid var(--forest); outline-offset: -1px; }

.code-display {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  background: var(--cream-2);
  border-radius: 100px;
  font-family: monospace;
  font-size: 14px;
  font-weight: 600;
  color: var(--forest);
  margin-top: 8px;
}

.hygiene-card { margin-top: 24px; }
.hygiene-card.has-stale {
  border-color: rgba(184, 84, 80, 0.4);
  background: linear-gradient(to bottom, rgba(184, 84, 80, 0.02), var(--surface) 30%);
}

.card-header-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 6px;
}
.card-header-row .card-title { margin-bottom: 0; }

.icon-btn {
  width: 36px; height: 36px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  border-radius: 10px;
  cursor: pointer;
  display: grid; place-items: center;
  color: var(--ink-soft);
  transition: all 0.15s;
  flex-shrink: 0;
}
.icon-btn:hover { background: var(--cream-2); color: var(--ink); }
.icon-btn.spinning svg { animation: rotate 1s linear; }
@keyframes rotate { to { transform: rotate(360deg); } }

.hygiene-summary {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 12px;
  margin: 18px 0;
}
.stat-tile {
  padding: 16px 14px;
  background: var(--cream-2);
  border-radius: 14px;
  border: 1px solid var(--border);
  text-align: center;
  transition: all 0.2s;
}
.stat-tile.warning {
  background: rgba(184, 84, 80, 0.06);
  border-color: rgba(184, 84, 80, 0.3);
}
.stat-tile.warning.zero {
  background: rgba(74, 124, 89, 0.05);
  border-color: rgba(74, 124, 89, 0.2);
}
.stat-num {
  font-family: 'Fraunces', serif;
  font-size: 28px;
  font-weight: 500;
  color: var(--ink);
  line-height: 1;
  letter-spacing: -0.02em;
}
.stat-tile.warning .stat-num { color: var(--error); }
.stat-tile.warning.zero .stat-num { color: var(--success); }
.stat-label {
  font-size: 11px;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 600;
  margin-top: 6px;
}

.cleanup-bar {
  display: none;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: rgba(184, 84, 80, 0.08);
  border: 1px solid rgba(184, 84, 80, 0.3);
  border-radius: 12px;
  margin-bottom: 18px;
}
.cleanup-bar.shown { display: flex; }
.cleanup-bar-text {
  flex: 1;
  font-size: 13px;
  color: var(--error);
  font-weight: 500;
}
.cleanup-bar button {
  padding: 8px 14px;
  background: var(--error);
  color: white;
  border: none;
  border-radius: 8px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
}
.cleanup-bar button:hover { background: #9F4844; }

.hygiene-list { display: flex; flex-direction: column; gap: 8px; }

.hygiene-empty {
  padding: 36px 20px;
  text-align: center;
  color: var(--ink-soft);
  font-size: 13px;
  font-style: italic;
  background: var(--cream-2);
  border-radius: 12px;
}

.hygiene-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--cream-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  transition: all 0.15s;
}
.hygiene-item.stale {
  background: rgba(184, 84, 80, 0.05);
  border-color: rgba(184, 84, 80, 0.25);
}
.hygiene-status-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--success);
  flex-shrink: 0;
  box-shadow: 0 0 0 3px rgba(74, 124, 89, 0.15);
}
.hygiene-item.stale .hygiene-status-dot {
  background: var(--error);
  box-shadow: 0 0 0 3px rgba(184, 84, 80, 0.18);
  animation: stalePulse 2.5s infinite;
}
@keyframes stalePulse {
  0%, 100% { box-shadow: 0 0 0 3px rgba(184, 84, 80, 0.18); }
  50% { box-shadow: 0 0 0 6px rgba(184, 84, 80, 0.05); }
}

.hygiene-info { flex: 1; min-width: 0; }
.hygiene-name {
  font-weight: 600;
  font-size: 13px;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.hygiene-meta {
  font-size: 12px;
  color: var(--ink-soft);
  margin-top: 2px;
  display: flex;
  gap: 8px;
  align-items: center;
}
.stale-tag {
  display: inline-block;
  background: var(--error);
  color: white;
  padding: 2px 8px;
  border-radius: 100px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.hygiene-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}
.hygiene-btn {
  width: 32px; height: 32px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  border-radius: 8px;
  cursor: pointer;
  display: grid; place-items: center;
  color: var(--ink-soft);
  transition: all 0.15s;
}
.hygiene-btn:hover { background: var(--cream-2); color: var(--ink); }
.hygiene-btn.danger:hover { background: var(--error); color: white; border-color: var(--error); }

.hygiene-disabled {
  padding: 20px;
  text-align: center;
  color: var(--ink-soft);
  font-size: 13px;
  background: var(--cream-2);
  border-radius: 12px;
}

.log-card { margin-top: 24px; }
.log-empty {
  padding: 40px 20px;
  text-align: center;
  color: var(--ink-soft);
  font-size: 14px;
  font-style: italic;
}
.log-list { display: flex; flex-direction: column; gap: 10px; }
.log-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  background: var(--cream-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  animation: slideIn 0.4s ease;
}
@keyframes slideIn {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}
.log-icon {
  width: 38px; height: 38px;
  background: var(--surface);
  border-radius: 10px;
  display: grid; place-items: center;
  flex-shrink: 0;
  color: var(--forest);
}
.log-info { flex: 1; min-width: 0; }
.log-name {
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.log-meta {
  font-size: 12px;
  color: var(--ink-soft);
  margin-top: 2px;
}
.log-status {
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 100px;
  background: rgba(74, 124, 89, 0.1);
  color: var(--success);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.progress {
  height: 4px;
  background: var(--border);
  border-radius: 100px;
  overflow: hidden;
  margin-top: 6px;
}
.progress-bar {
  height: 100%;
  background: var(--forest);
  transition: width 0.2s;
}

#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 1000;
}
.toast {
  background: var(--ink);
  color: var(--cream);
  padding: 14px 20px;
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  font-size: 14px;
  font-weight: 500;
  animation: toastIn 0.3s ease;
  max-width: 360px;
}
.toast.success { background: var(--success); }
.toast.error { background: var(--error); }
@keyframes toastIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

.browser-warning {
  background: rgba(184, 84, 80, 0.08);
  border: 1px solid rgba(184, 84, 80, 0.25);
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 20px;
  font-size: 13px;
  color: var(--error);
}
