:root {
  --bg: #f6f8f4;
  --fg: #1f2a1f;
  --accent: #3f7d3f;
  --card: #ffffff;
  --border: #d8e0d4;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14180f;
    --fg: #e8ede4;
    --accent: #7fbf7f;
    --card: #1e2419;
    --border: #313b29;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--fg);
  padding-bottom: env(safe-area-inset-bottom);
}

.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-box {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 2rem;
  text-align: center;
  min-width: 280px;
}
.login-box input {
  font-size: 1.5rem;
  letter-spacing: 0.3em;
  text-align: center;
  padding: 0.5rem;
  width: 100%;
  margin: 1rem 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--fg);
}
.login-box button {
  background: var(--accent);
  color: white;
  border: none;
  padding: 0.6rem 1.5rem;
  border-radius: 8px;
  font-size: 1rem;
  cursor: pointer;
}
.error { color: #c0392b; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding: 0 1rem;
  padding-top: env(safe-area-inset-top);
}
.topbar-inner {
  max-width: 960px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 1rem;
  height: 56px;
}
.topbar .logo { font-weight: 700; letter-spacing: -0.02em; }
.topbar nav { display: flex; gap: 1.25rem; flex: 1; }
.topbar nav a { color: var(--fg); opacity: 0.65; text-decoration: none; font-size: 0.95rem; transition: opacity 0.15s; }
.topbar nav a:hover { opacity: 0.9; }
.topbar nav a.active { opacity: 1; font-weight: 600; color: var(--accent); }
.topbar .logout { color: var(--fg); opacity: 0.6; text-decoration: none; font-size: 0.9rem; white-space: nowrap; }

main { max-width: 960px; margin: 0 auto; padding: 0 1.5rem; }

.hero { padding: 2.5rem 0 1.5rem; }
.badge {
  display: inline-block;
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
  color: var(--accent);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0.25rem 0.75rem;
  border-radius: 2rem;
  margin-bottom: 1rem;
}
.hero h1 { font-size: clamp(1.6rem, 5vw, 2.4rem); margin: 0 0 0.75rem; letter-spacing: -0.02em; }
.hero-sub { color: var(--fg); opacity: 0.7; max-width: 560px; line-height: 1.6; margin: 0; }

.section { padding: 2rem 0; border-top: 1px solid var(--border); }
.section .label {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 0.4rem;
}
.section h2 { font-size: 1.3rem; margin: 0 0 1.25rem; letter-spacing: -0.01em; }

footer { border-top: 1px solid var(--border); padding: 1.5rem 1rem; margin-top: 2rem; padding-bottom: calc(1.5rem + env(safe-area-inset-bottom)); }
.footer-inner { max-width: 960px; margin: 0 auto; font-size: 0.8rem; opacity: 0.6; }

.plot-fact { font-size: 1.05rem; line-height: 1.6; }
.specs-table { border-collapse: collapse; margin-top: 1rem; width: 100%; max-width: 480px; }
.specs-table td { padding: 0.4rem 0.75rem 0.4rem 0; border-bottom: 1px solid var(--border); font-size: 0.9rem; }
.specs-table td:first-child { opacity: 0.7; }
.specs-table td:last-child { font-weight: 600; text-align: right; padding-right: 0; }
.huette-sketch { margin: 1rem 0 1.5rem; }
.huette-sketch img { width: 100%; border-radius: 8px; border: 1px solid var(--border); display: block; }

@media (max-width: 640px) {
  .topbar-inner { gap: 0.75rem; }
  .topbar nav { gap: 0.85rem; }
  .topbar .logout { font-size: 0.8rem; }
}

#dropzone {
  border: 2px dashed var(--border);
  border-radius: 12px;
  padding: 2rem;
  text-align: center;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
}
#dropzone.dragover { background: var(--card); border-color: var(--accent); }
#dropzone.upload-cta {
  border-style: solid;
  border-color: var(--accent);
  border-width: 3px;
  padding: 2.5rem;
  font-size: 1.1rem;
  font-weight: 600;
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 18%, transparent);
  animation: upload-cta-pulse 1.6s ease-in-out infinite;
}
@keyframes upload-cta-pulse {
  0%, 100% { box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 18%, transparent); }
  50% { box-shadow: 0 0 0 10px color-mix(in srgb, var(--accent) 8%, transparent); }
}

#resume-hint {
  background: color-mix(in srgb, var(--accent) 10%, var(--card));
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.9rem 1.1rem;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}
#resume-hint p { margin: 0 0 0.6rem; line-height: 1.5; }
.resume-actions { display: flex; gap: 0.6rem; flex-wrap: wrap; }
.resume-actions button {
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--fg);
  border-radius: 6px;
  padding: 0.35rem 0.8rem;
  font-size: 0.85rem;
  cursor: pointer;
}
#resume-pick { border-color: var(--accent); color: var(--accent); font-weight: 600; }

#queue-summary { font-size: 0.85rem; opacity: 0.75; margin: 0.75rem 0 0.25rem; }

#upload-queue { list-style: none; padding: 0; margin: 1rem 0; }
.queue-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.4rem 0;
  border-bottom: 1px solid var(--border);
}
.queue-thumb { width: 32px; height: 32px; display: flex; align-items: center; justify-content: center; flex: none; }
.queue-thumb img { width: 100%; height: 100%; object-fit: cover; border-radius: 4px; }
.queue-label { flex: 1; font-size: 0.9rem; }
.queue-status { font-size: 0.85rem; opacity: 0.7; }
.queue-status.ok { color: var(--accent); }
.queue-status.err { color: #c0392b; }
.queue-status.busy { color: var(--fg); opacity: 0.85; }
.queue-status.warn { color: #b7791f; opacity: 1; }
.queue-retry-btn {
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--fg);
  border-radius: 4px;
  padding: 0.1rem 0.4rem;
  font-size: 0.8rem;
  cursor: pointer;
}

#gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 0.5rem;
  margin: 1rem 0 2rem;
}
.gallery-item {
  display: block;
  aspect-ratio: 1;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: var(--card);
  font-size: 0.75rem;
  text-decoration: none;
  color: var(--fg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.25rem;
  text-align: center;
  word-break: break-all;
}
.gallery-item img { width: 100%; height: 100%; object-fit: cover; }

.gallery-wrap { position: relative; }
.gallery-propose {
  position: absolute;
  bottom: 4px;
  right: 4px;
  border: none;
  background: rgba(0,0,0,0.55);
  color: white;
  border-radius: 50%;
  width: 26px;
  height: 26px;
  font-size: 0.85rem;
  cursor: pointer;
  line-height: 1;
}
.gallery-propose:disabled { opacity: 0.6; cursor: default; }
.gallery-used {
  position: absolute;
  top: 4px;
  left: 4px;
  background: rgba(63,125,63,0.85);
  color: white;
  font-size: 0.65rem;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  line-height: 1.4;
}

#text-propose {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 1rem;
}
#text-propose textarea {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.5rem;
  font-family: inherit;
  font-size: 0.9rem;
  background: var(--bg);
  color: var(--fg);
  min-height: 60px;
  resize: vertical;
}
#text-propose button {
  align-self: flex-start;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 6px;
  padding: 0.4rem 1rem;
  cursor: pointer;
  font-size: 0.9rem;
}
#text-propose-status { font-size: 0.85rem; opacity: 0.75; }

.empty-state { opacity: 0.7; font-style: italic; }

.beds { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1.5rem; }
.bed-card {
  position: relative;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem;
}
.egg {
  position: absolute;
  top: 0.4rem;
  right: 0.5rem;
  font-size: 0.85rem;
  opacity: 0.25;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.15s;
  line-height: 1;
}
.egg:hover { opacity: 0.85; transform: scale(1.2); }
.egg.egg-new {
  opacity: 1;
  padding: 3px 4px;
  border-radius: 50%;
  background: linear-gradient(160deg, #ff6b6b 0%, #ffd93d 34%, #6bcf7f 67%, #4d96ff 100%);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 30%, transparent);
  animation: egg-new-pulse 1.8s ease-in-out infinite;
}
@keyframes egg-new-pulse {
  0%, 100% { box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 30%, transparent); }
  50% { box-shadow: 0 0 0 6px color-mix(in srgb, var(--accent) 12%, transparent); }
}
.nav-egg {
  display: inline-block;
  margin-left: 0.3rem;
  padding: 1px 3px;
  border-radius: 50%;
  background: linear-gradient(160deg, #ff6b6b 0%, #ffd93d 34%, #6bcf7f 67%, #4d96ff 100%);
  font-size: 0.75rem;
  vertical-align: middle;
  animation: egg-new-pulse 1.8s ease-in-out infinite;
}
.bed-date { font-size: 0.75rem; opacity: 0.55; margin: -0.5rem 0 0.5rem; }
.bed-image-wrap { position: relative; margin: 0.5rem 0; }
.bed-image-wrap img { width: 100%; border-radius: 8px; display: block; }
.hotspot { position: absolute; transform: translate(-50%, -50%); }
.hotspot-dot {
  display: block;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid white;
  box-shadow: 0 0 0 2px var(--accent);
}
.hotspot-label {
  position: absolute;
  left: 20px;
  top: -4px;
  background: rgba(0,0,0,0.75);
  color: white;
  font-size: 0.75rem;
  padding: 2px 6px;
  border-radius: 4px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s;
}
.hotspot:hover .hotspot-label { opacity: 1; }

.plant-list { padding-left: 1.2rem; }
.bed-desc { color: var(--fg); opacity: 0.85; }
