/* ── Reset ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

:root {
  --bg:        #faf7f2;
  --surface:   #ffffff;
  --accent:    #f59e0b;
  --accent-hi: #d97706;
  --text:      #1c1917;
  --muted:     #78716c;
  --border:    #e7e5e4;
  --shadow:    rgba(0,0,0,0.07);
  --danger:    #ef4444;
  --danger-hi: #dc2626;
}

html, body { height: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.55;
}

/* ── Typography ────────────────────────────────────────────── */
h2 { font-size: 1.3rem; font-weight: 700; margin-bottom: 0.2rem; }
h3 { font-size: 1rem; font-weight: 700; margin-bottom: 0.2rem; }

code {
  font-family: 'Courier New', Courier, monospace;
  background: var(--bg);
  padding: 0.1em 0.4em;
  border-radius: 4px;
  font-size: 0.9em;
  letter-spacing: 0.04em;
}

/* ── Buttons ───────────────────────────────────────────────── */
button, a.btn-primary, a.btn-secondary {
  font-family: inherit;
  text-decoration: none;
}

.btn-primary, .btn-secondary, .btn-ghost, .btn-icon, .copy-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  border-radius: 8px;
  border: 1.5px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.14s, border-color 0.14s, color 0.14s;
  padding: 0.6rem 1.25rem;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.btn-primary:hover { background: var(--accent-hi); border-color: var(--accent-hi); }

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
}
.btn-secondary:hover { border-color: var(--accent); color: var(--accent); }

.btn-ghost {
  background: none;
  color: var(--muted);
  border-color: var(--border);
  padding: 0.35rem 0.85rem;
  font-size: 0.84rem;
}
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }

.btn-icon {
  background: none;
  border: none;
  padding: 0.3rem 0.45rem;
  font-size: 1rem;
  border-radius: 6px;
  color: var(--muted);
}
.btn-icon:hover { background: var(--bg); color: var(--text); }

.full-width { width: 100%; }

.copy-btn {
  background: none;
  border-color: var(--border);
  color: var(--muted);
  font-size: 0.76rem;
  padding: 0.2rem 0.55rem;
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
}
.copy-btn:hover { border-color: var(--accent); color: var(--accent); }

/* ── Header ────────────────────────────────────────────────── */
.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 0.875rem;
  padding: 0.8rem 1.5rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.header-left {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-width: 0;
}

.logo {
  font-size: 1.7rem;
  font-weight: 700;
  color: #543318;
  text-decoration: none;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.header-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
}

.header-stash-name {
  font-size: 0.86rem;
  color: var(--muted);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-stash-id {
  font-family: 'Courier New', Courier, monospace;
  font-weight: 700;
  color: var(--muted);
}

.squirrel {
  display: inline-block;
  transform: scaleX(-1);
}

.stash-name-header {
  flex: 1;
  font-size: 0.86rem;
  color: var(--muted);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-right {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.6rem;
}

.header-right .close-stash-btn,
.header-right .btn-ghost {
  height: 36px;
  padding-top: 0;
  padding-bottom: 0;
}

.close-stash-btn {
  display: inline-flex;
  align-items: center;
  padding: 0.35rem 0.9rem;
  font-size: 0.84rem;
  font-weight: 600;
  font-family: inherit;
  border-radius: 8px;
  border: 1.5px solid var(--accent);
  background: var(--accent);
  color: #fff;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.14s, border-color 0.14s;
}
.close-stash-btn:hover { background: var(--accent-hi); border-color: var(--accent-hi); }

/* ── Cards ─────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.75rem;
  box-shadow: 0 2px 10px var(--shadow);
}

.card-sub {
  color: var(--muted);
  font-size: 0.86rem;
  margin-bottom: 1.25rem;
}

/* ── Forms ─────────────────────────────────────────────────── */
.field {
  display: flex;
  flex-direction: column;
  gap: 0.28rem;
  margin-bottom: 0.9rem;
}

label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text);
}

.optional {
  font-weight: 400;
  color: var(--muted);
  font-size: 0.75rem;
  margin-left: 0.2em;
}

input[type=text],
input[type=email],
input[type=password] {
  padding: 0.52rem 0.75rem;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 0.95rem;
  font-family: inherit;
  background: var(--bg);
  color: var(--text);
  outline: none;
  width: 100%;
  transition: border-color 0.14s;
}
input:focus { border-color: var(--accent); }

.form-error {
  color: var(--danger);
  font-size: 0.8rem;
  min-height: 1.1em;
  margin-bottom: 0.4rem;
}

.form-success {
  color: #16a34a;
  font-size: 0.84rem;
  margin-bottom: 0.75rem;
}

.card-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 1.5rem 0;
}

.recover-label {
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 0.75rem;
}

/* ── Danger zone ───────────────────────────────────────────── */
.rename-form { margin: 1rem 0 1.25rem; }
.rename-status {
  display: block;
  margin-top: 0.5rem;
  text-align: center;
  font-size: 0.82rem;
  color: var(--accent);
}

.print-hint {
  margin: 0.75rem 0 0.5rem;
  font-size: 0.82rem;
  line-height: 1.5;
  color: var(--muted);
}

.settings-print {
  margin: 0 0 1.25rem;
  background: none;
  border-color: var(--accent);
  color: var(--accent);
}

#recover-btn {
  background: none;
  border-color: var(--accent);
  color: var(--accent);
}

.settings-danger {
  display: flex;
  justify-content: center;
  margin-top: 1.25rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
}

.btn-clear-stash {
  font-family: inherit;
  font-size: 0.84rem;
  font-weight: 600;
  padding: 0.45rem 1.1rem;
  border-radius: 8px;
  border: 1.5px solid var(--danger);
  background: none;
  color: var(--danger);
  cursor: pointer;
  transition: background 0.14s, color 0.14s;
}
.btn-clear-stash:hover { background: var(--danger); color: #fff; }

/* ── Home layout ───────────────────────────────────────────── */
.home-main {
  max-width: 840px;
  margin: 2.25rem auto;
  padding: 0 1rem;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
  align-items: stretch;
}

@media (max-width: 580px) {
  .home-main { grid-template-columns: 1fr; }

  .site-header { flex-wrap: wrap; row-gap: 0.5rem; }
  .header-left { order: 1; flex: 0 1 auto; }
  .header-right { order: 2; flex: 0 0 auto; margin-left: auto; justify-content: flex-end; }
  .header-center {
    order: 3;
    flex: 1 1 100%;
    align-items: center;
  }
}

/* ── Success card ──────────────────────────────────────────── */
.success-card {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0.875rem;
}

.success-icon {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: #dcfce7;
  color: #16a34a;
  font-size: 1.4rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.stash-id-row {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.45rem 0.7rem;
  align-self: stretch;
  justify-content: center;
}

.stash-id-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  white-space: nowrap;
}

/* ── QR containers ─────────────────────────────────────────── */
.qr-container canvas,
.qr-container img {
  border: 8px solid #fff;
  border-radius: 10px;
  box-shadow: 0 2px 14px var(--shadow);
  display: block;
}

/* ── Centered layout ───────────────────────────────────────── */
.centered {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 57px);
  padding: 2rem 1rem;
}

.centered-top {
  align-items: flex-start;
  padding-top: 3rem;
}

.chestnut-rain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 9999;
}
.chestnut-drop {
  position: absolute;
  top: 0;
  left: 0;
  line-height: 1;
  will-change: transform;
  pointer-events: auto;
  cursor: grab;
}
.chestnut-drop:active { cursor: grabbing; }

.tilt-hint {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0.5rem;
  text-align: center;
  font-size: 0.75rem;
  color: var(--muted);
  pointer-events: none;
  z-index: 10000;
}

.login-card { width: 100%; max-width: 380px; }

.forgot-pin {
  text-align: center;
  margin-top: 1rem;
  font-size: 0.84rem;
}
.forgot-pin a { color: var(--accent); text-decoration: none; }
.forgot-pin a:hover { text-decoration: underline; }

.forgot-pin-sent {
  text-align: center;
  margin-top: 1rem;
  font-size: 0.84rem;
  color: var(--muted);
}

.login-top {
  text-align: center;
  margin-bottom: 1.5rem;
}

.login-icon { font-size: 2.25rem; margin-bottom: 0.5rem; }

.stash-id-small {
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 0.25rem;
}

/* ── Notes section ─────────────────────────────────────────── */
.notes-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}

.notes-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.65rem 0.875rem 0;
}

.notes-header .section-label { margin-bottom: 0; }

.notes-status {
  font-size: 0.75rem;
  color: #16a34a;
  font-weight: 500;
  opacity: 0;
  transition: opacity 0.3s;
}

.notes-status.visible { opacity: 1; }

.stash-notes {
  display: block;
  width: 100%;
  padding: 0.65rem 0.875rem 0.875rem;
  border: none;
  outline: none;
  resize: vertical;
  overflow-y: scroll;
  font-family: inherit;
  font-size: 0.92rem;
  line-height: 1.6;
  color: var(--text);
  background: var(--surface);
  min-height: 110px;
}

.stash-notes::placeholder { color: var(--muted); }

/* ── Stash main ────────────────────────────────────────────── */
.stash-main {
  max-width: 720px;
  margin: 2rem auto;
  padding: 0 1rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* ── Upload collapsible ────────────────────────────────────── */
.upload-summary {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0;
  cursor: pointer;
  list-style: none;
  user-select: none;
}
.upload-summary::-webkit-details-marker { display: none; }
.upload-summary::before {
  content: '+';
  font-size: 1.1em;
}
.upload-details[open] .upload-summary::before { content: '−'; }
.upload-details[open] .upload-summary { margin-bottom: 0.75rem; }

/* ── Drop zone ─────────────────────────────────────────────── */
.drop-zone {
  max-width: 50%;
  margin-inline: auto;
  border: 2px dashed var(--border);
  border-radius: 12px;
  padding: 1.1rem 1.5rem;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.45rem;
  color: var(--muted);
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.drop-zone.drag-over {
  border-color: var(--accent);
  background: #fffbeb;
}

.or { font-size: 0.8rem; }

.choose-label { cursor: pointer; }

/* ── Upload progress ───────────────────────────────────────── */
.upload-progress {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.625rem;
}

.upload-item {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  font-size: 0.83rem;
  color: var(--muted);
}

.upload-fname {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 160px;
  flex-shrink: 0;
}

.upload-bar-wrap {
  flex: 1;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}

.upload-bar {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.15s;
}

/* ── Files section ─────────────────────────────────────────── */
.section-label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 0.65rem;
}

.file-count { font-weight: 400; }

.empty-msg {
  color: var(--muted);
  font-size: 0.875rem;
}

.file-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.file-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 9px;
  transition: border-color 0.12s;
}

.file-row:hover { border-color: #d4cfc8; }

.file-icon { font-size: 1.2rem; flex-shrink: 0; width: 48px; text-align: center; }

.file-thumb {
  width: 48px;
  height: 48px;
  border-radius: 6px;
  overflow: hidden;
  flex-shrink: 0;
  cursor: pointer;
}

.photo-modal-img {
  position: relative;
  max-width: 92vw;
  max-height: 88vh;
  border-radius: 8px;
  box-shadow: 0 16px 48px rgba(0,0,0,0.4);
  cursor: zoom-out;
}

.file-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.file-meta {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.file-name {
  font-size: 0.9rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-info {
  font-size: 0.76rem;
  color: var(--muted);
}

.file-actions {
  display: flex;
  gap: 0.15rem;
  flex-shrink: 0;
}

/* ── Label modal ───────────────────────────────────────────── */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal[hidden] { display: none; }

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15,10,5,0.45);
}

.settings-modal {
  position: relative;
  background: var(--surface);
  border-radius: 16px;
  padding: 1.75rem;
  box-shadow: 0 16px 48px rgba(0,0,0,0.18);
  width: 92%;
  max-width: 380px;
}

.settings-modal h3 { margin-bottom: 0.25rem; }
.settings-modal .card-sub { margin-bottom: 1.25rem; }
.settings-modal .label-modal-btns { margin-top: 0.5rem; }

.label-modal {
  position: relative;
  background: var(--surface);
  border-radius: 16px;
  padding: 1.75rem;
  box-shadow: 0 16px 48px rgba(0,0,0,0.18);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  width: 92%;
  max-width: 580px;
}

.label-modal h3 { align-self: flex-start; }
.label-modal .card-sub { align-self: flex-start; margin-bottom: 0; }

.label-previews {
  display: flex;
  gap: 1.5rem;
  align-items: flex-start;
  justify-content: center;
}

.label-preview-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
}

.label-size-tag {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* Label cards — screen preview uses px, print uses in */
.label-card {
  background: #fff;
  border: 1.5px solid #ccc;
  border-radius: 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  box-shadow: 0 2px 8px rgba(0,0,0,0.10);
}

.label-lg {
  width: 192px;
  height: 192px;
  padding: 10px 8px 8px;
  gap: 3px;
}

.label-md {
  width: 144px;
  height: 144px;
  padding: 8px 6px 6px;
  gap: 2px;
}

.label-sm {
  width: 96px;
  height: 96px;
  padding: 5px 4px 4px;
  gap: 2px;
}

.label-brand {
  font-size: 8px;
  font-weight: 700;
  color: #1c1917;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.label-name {
  font-size: 7.5px;
  font-weight: 600;
  color: #44403c;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.label-qr { line-height: 0; }
.label-qr canvas { display: block; }

.label-stash-id {
  font-size: 6.5px;
  font-family: 'Courier New', Courier, monospace;
  font-weight: 700;
  color: #000;
}

.label-stash-id-sm {
  font-size: 5px;
}

.label-modal-btns {
  display: flex;
  gap: 0.5rem;
  width: 100%;
}

.label-modal-btns .btn-secondary,
.label-modal-btns .btn-primary {
  flex: 1;
}
