:root {
  --canvas: #ffffff;
  --parchment: #f5f5f6;
  --ink: #1d1d1f;
  --muted: #6e6e73;
  --hairline: #e3e1e1;
  --aka: #e00000;
  --aka-deep: #b50000;
  --aka-soft: rgba(224, 0, 0, 0.08);
  --tile: #1c1b1c;
  --display: "Inter Tight", system-ui, -apple-system, "Segoe UI", sans-serif;
  --body: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 12px 32px rgba(0, 0, 0, 0.10);
  color-scheme: light;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  background: var(--canvas);
  color: var(--ink);
  font-family: var(--body);
  font-size: 13px;
  -webkit-font-smoothing: antialiased;
}

/* Topbar */
.topbar {
  height: 56px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: saturate(180%) blur(16px);
  border-bottom: 1px solid var(--hairline);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  gap: 16px;
  position: relative;
  z-index: 20;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.ring-logo {
  width: 26px;
  height: 26px;
  flex: none;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.brand-name {
  font-family: var(--display);
  font-weight: 700;
  font-size: 16px;
  letter-spacing: -0.02em;
}

.brand-studio {
  font-size: 11px;
  color: var(--muted);
}

.loc-pill {
  background: var(--parchment);
  border: 1px solid var(--hairline);
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 12px;
  color: var(--ink);
  font-weight: 500;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

button, .file-btn {
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  border-radius: 8px;
  transition: all 0.15s ease;
}

.btn-outline {
  background: var(--canvas);
  color: var(--ink);
  border: 1px solid var(--hairline);
  padding: 7px 12px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-outline:hover {
  border-color: var(--ink);
  background: var(--parchment);
}

.btn-primary {
  background: var(--aka);
  color: #fff;
  border: 1px solid var(--aka);
  padding: 7px 14px;
  font-weight: 600;
}

.btn-primary:hover {
  background: var(--aka-deep);
  border-color: var(--aka-deep);
}

.btn-secondary {
  background: var(--ink);
  color: #fff;
  border: 1px solid var(--ink);
  padding: 7px 12px;
  font-weight: 600;
}

.btn-secondary:hover {
  opacity: 0.88;
}

.btn-icon {
  background: var(--parchment);
  border: 1px solid var(--hairline);
  color: var(--ink);
  width: 34px;
  height: 32px;
  display: grid;
  place-items: center;
}

/* Workspace */
.workspace {
  display: flex;
  height: calc(100vh - 56px);
  position: relative;
}

/* Drawer */
.drawer {
  width: 348px;
  flex: none;
  background: var(--parchment);
  border-right: 1px solid var(--hairline);
  height: 100%;
  transition: margin-left 0.25s ease;
  z-index: 15;
}

.drawer.collapsed {
  margin-left: -348px;
}

.drawer-scroll {
  height: 100%;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.panel-card {
  background: var(--canvas);
  border: 1px solid var(--hairline);
  border-radius: 12px;
  padding: 14px;
  box-shadow: var(--shadow-sm);
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.panel-head h2 {
  margin: 0;
  font-family: var(--display);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.tag-online {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--aka);
  background: var(--aka-soft);
  padding: 3px 7px;
  border-radius: 999px;
}

.muted-small {
  font-size: 11px;
  color: var(--muted);
}

.link-btn {
  background: none;
  border: none;
  color: var(--aka);
  font-weight: 600;
  font-size: 11px;
  padding: 2px 4px;
}

.link-btn:hover { text-decoration: underline; }

.search-row {
  display: flex;
  gap: 6px;
  margin-bottom: 8px;
}

input[type="text"], input[type="number"], select {
  width: 100%;
  padding: 7px 9px;
  border: 1px solid var(--hairline);
  border-radius: 7px;
  background: var(--parchment);
  color: var(--ink);
  font-family: inherit;
  font-size: 12px;
}

input:focus, select:focus {
  outline: 2px solid var(--aka);
  outline-offset: -1px;
  background: var(--canvas);
}

.coord-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 8px;
}

.coord-grid label {
  display: block;
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 3px;
}

.search-results {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 6px;
}

.search-item {
  padding: 7px 9px;
  border: 1px solid var(--hairline);
  border-radius: 7px;
  font-size: 12px;
  cursor: pointer;
  background: var(--canvas);
}

.search-item:hover {
  border-color: var(--aka);
  background: var(--aka-soft);
}

.status-msg {
  margin-top: 8px;
  font-size: 11px;
  color: var(--muted);
  padding: 6px 8px;
  border-radius: 6px;
  background: var(--parchment);
}

.status-msg.ok { background: #eaf7ee; color: #1a6b35; }
.status-msg.err { background: #fdecec; color: #b50000; }

/* Wind Rose */
.rose-wrap {
  display: flex;
  justify-content: center;
  margin: 4px 0 8px;
}

#windRoseCanvas {
  width: 210px;
  height: 210px;
}

.wind-summary {
  font-size: 12px;
  padding: 8px 10px;
  background: var(--parchment);
  border-radius: 8px;
  margin-bottom: 8px;
  line-height: 1.4;
}

.wind-summary b { color: var(--aka); }

.season-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
}

.season-table td {
  padding: 4px 2px;
  border-top: 1px solid var(--hairline);
  color: var(--muted);
}

.season-table td:last-child {
  text-align: right;
  color: var(--ink);
  font-weight: 500;
}

/* Dropzone & Sliders */
.dropzone {
  border: 1.5px dashed var(--hairline);
  border-radius: 8px;
  padding: 10px;
  text-align: center;
  font-size: 11px;
  color: var(--muted);
  background: var(--parchment);
  margin-bottom: 12px;
  transition: all 0.15s;
}

.dropzone.dragover {
  border-color: var(--aka);
  background: var(--aka-soft);
  color: var(--ink);
}

.slider-row {
  margin-bottom: 10px;
}

.slider-label {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  margin-bottom: 4px;
}

.slider-label strong {
  color: var(--ink);
  font-weight: 600;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--aka);
  cursor: pointer;
}

.toggles-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--hairline);
}

.toggle-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  cursor: pointer;
  padding: 2px 0;
}

.toggle-item input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 34px;
  height: 19px;
  background: #d2d2d7;
  border-radius: 999px;
  position: relative;
  cursor: pointer;
  transition: 0.15s;
}

.toggle-item input[type="checkbox"]::after {
  content: "";
  position: absolute;
  top: 2.5px;
  left: 2.5px;
  width: 14px;
  height: 14px;
  background: #fff;
  border-radius: 50%;
  transition: 0.15s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.toggle-item input[type="checkbox"]:checked {
  background: var(--aka);
}

.toggle-item input[type="checkbox"]:checked::after {
  left: 17.5px;
}

.drawer-footer {
  font-size: 11px;
  color: var(--muted);
  text-align: center;
  padding: 4px 6px 10px;
  line-height: 1.4;
}

.drawer-footer a {
  color: var(--aka);
  text-decoration: none;
}

/* Viewport 3D */
.viewport-area {
  flex: 1;
  position: relative;
  height: 100%;
  background: var(--parchment);
  overflow: hidden;
}

#canvas3d {
  width: 100%;
  height: 100%;
  display: block;
}

/* HUD Top Right */
.hud-top-right {
  position: absolute;
  top: 16px;
  right: 16px;
  display: flex;
  gap: 10px;
  pointer-events: none;
}

.hud-chip {
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(14px);
  border: 1px solid var(--hairline);
  border-radius: 10px;
  padding: 8px 12px;
  display: flex;
  align-items: center;
  gap: 9px;
  box-shadow: var(--shadow-sm);
}

.hud-chip small {
  display: block;
  font-size: 10px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.hud-chip strong {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink);
}

.hud-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex: none;
}

.sun-dot { background: #f2994a; box-shadow: 0 0 0 3px rgba(242, 153, 74, 0.25); }
.wind-dot { background: var(--aka); box-shadow: 0 0 0 3px rgba(224, 0, 0, 0.18); }

/* HUD Bottom */
.hud-bottom {
  position: absolute;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  width: min(640px, calc(100% - 32px));
  background: rgba(255, 255, 255, 0.90);
  backdrop-filter: blur(18px);
  border: 1px solid var(--hairline);
  border-radius: 14px;
  padding: 12px 16px;
  box-shadow: var(--shadow-md);
}

.hud-time-row {
  display: flex;
  align-items: center;
  gap: 14px;
}

.play-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: var(--aka);
  color: #fff;
  font-size: 13px;
  display: grid;
  place-items: center;
  flex: none;
}

.play-btn:hover { background: var(--aka-deep); }

.time-slider-wrap, .day-slider-wrap {
  flex: 1;
}

.time-header {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 2px;
}

.time-header strong {
  color: var(--ink);
  font-size: 12px;
}

.season-pills {
  display: flex;
  gap: 6px;
  margin-top: 8px;
  flex-wrap: wrap;
}

.pill {
  flex: 1;
  min-width: 110px;
  padding: 5px 8px;
  border-radius: 999px;
  border: 1px solid var(--hairline);
  background: var(--canvas);
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
}

.pill:hover { border-color: var(--ink); color: var(--ink); }

.pill.active {
  background: var(--aka);
  border-color: var(--aka);
  color: #fff;
  font-weight: 600;
}

@media (max-width: 820px) {
  .topbar-center { display: none; }
  .drawer { position: absolute; left: 0; top: 0; bottom: 0; }
  .hud-top-right { display: none; }
}
