@import "./tokens.css";

* { box-sizing: border-box; }

body {
  margin: 0;
  background:
    radial-gradient(1200px 500px at 70% -10%, rgba(94, 119, 217, 0.14), transparent 60%),
    radial-gradient(900px 420px at 8% 110%, rgba(111, 217, 201, 0.05), transparent 55%),
    var(--bg);
  color: var(--text);
  font: 400 13.5px/1.5 "Outfit", system-ui, sans-serif;
  letter-spacing: 0.01em;
  height: 100vh;
  overflow: hidden;
}

#app { display: flex; flex-direction: column; height: 100vh; }

/* ------------------------------------------------------------- top bar */

.topbar {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 10px 20px;
  background: rgba(13, 18, 38, 0.82);
  border-bottom: 1px solid var(--border-soft);
  backdrop-filter: blur(10px);
}

.brand { display: flex; align-items: center; gap: 11px; user-select: none; }
a.brand { color: inherit; text-decoration: none; }
a.brand:hover .wordmark { color: var(--accent-strong); }

.orb { width: 30px; height: 30px; }
.orb circle { transform-origin: 50% 50%; }
.orb .ring { animation: none; }
body.playing .orb .ring1 { animation: breathe 6s ease-in-out infinite; }
body.playing .orb .ring2 { animation: breathe 6s ease-in-out infinite 0.35s; }
body.playing .orb .ring3 { animation: breathe 6s ease-in-out infinite 0.7s; }

@keyframes breathe {
  0%, 100% { transform: scale(1); opacity: 0.45; }
  50% { transform: scale(1.14); opacity: 1; }
}

.wordmark {
  font-size: 19px;
  font-weight: 600;
  letter-spacing: 0.04em;
}
.wordmark b { color: var(--accent); font-weight: 600; }

.tagline {
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  margin-left: 2px;
}

/* ------------------------------------------------------- transport bar */

.transport-bar {
  display: flex;
  align-items: center;
  gap: 22px;
  padding: 10px 22px;
  background: rgba(13, 18, 38, 0.88);
  border-top: 1px solid var(--border-soft);
  backdrop-filter: blur(10px);
}

.tb-left {
  width: 228px;
  display: flex;
  flex-direction: column;
  gap: 1px;
  overflow: hidden;
}
.tb-title {
  font-size: 13.5px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tb-sub { font-size: 11px; color: var(--muted); }

.tb-center {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.tb-time {
  font-variant-numeric: tabular-nums;
  font-size: 12px;
  color: var(--muted);
  min-width: 38px;
  text-align: center;
}

.tb-right { display: flex; align-items: center; gap: 16px; }

.icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid transparent;
  color: var(--muted);
}
.icon-btn:hover { color: var(--text); background: rgba(143, 168, 255, 0.1); border-color: transparent; }
.icon-btn svg { width: 14px; height: 14px; }

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  border-radius: 2px;
  background: var(--raised);
  outline: none;
  border: none;
  padding: 0;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: #e8ecf8;
  box-shadow: 0 0 8px rgba(143, 168, 255, 0.7);
  transition: transform 0.12s ease;
}
input[type="range"]::-webkit-slider-thumb:hover { transform: scale(1.25); }
input[type="range"]::-moz-range-thumb {
  width: 13px;
  height: 13px;
  border: none;
  border-radius: 50%;
  background: #e8ecf8;
  box-shadow: 0 0 8px rgba(143, 168, 255, 0.7);
}
.seek { flex: 1; min-width: 120px; }

.volume {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
}
.volume svg { width: 15px; height: 15px; }
.vol { width: 86px; }

.play-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(145deg, var(--accent), var(--accent-dim));
  color: #0a1026;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 18px rgba(143, 168, 255, 0.35);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.play-btn:hover { transform: scale(1.06); box-shadow: 0 6px 22px rgba(143, 168, 255, 0.5); }
.play-btn:active { transform: scale(0.97); }
.play-btn svg { width: 17px; height: 17px; display: block; }

.time-readout {
  font-variant-numeric: tabular-nums;
  font-size: 13px;
  color: var(--muted);
  min-width: 110px;
}
.time-readout b { color: var(--text); font-weight: 500; }

.beat-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 4px 12px;
  border-radius: 999px;
  background: rgba(143, 168, 255, 0.1);
  border: 1px solid rgba(143, 168, 255, 0.25);
  font-size: 12px;
  color: var(--accent-strong);
  font-variant-numeric: tabular-nums;
}
.beat-pill .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
}
body.playing .beat-pill .dot { animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 0.35; } 50% { opacity: 1; } }

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

/* menus */

.menu { position: relative; }
.menu-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  min-width: 190px;
  background: var(--raised);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow);
  padding: 6px;
  display: none;
  z-index: 60;
}
.menu.open .menu-panel { display: block; }
.menu-item {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  color: var(--text);
  padding: 8px 12px;
  border-radius: var(--r-sm);
  font: inherit;
  cursor: pointer;
}
.menu-item:hover { background: rgba(143, 168, 255, 0.12); }
.menu-sep { height: 1px; background: var(--border-soft); margin: 6px 4px; }

/* ------------------------------------------------------------- buttons */

button {
  background: rgba(143, 168, 255, 0.08);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 6px 13px;
  font: 500 12.5px "Outfit", system-ui, sans-serif;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}
button:hover { background: rgba(143, 168, 255, 0.16); border-color: var(--accent-dim); }
button:active { transform: translateY(1px); }
button:disabled { opacity: 0.4; cursor: default; }

button.accent {
  background: linear-gradient(145deg, var(--accent), var(--accent-dim));
  border: none;
  color: #0a1026;
  font-weight: 600;
  box-shadow: 0 3px 14px rgba(143, 168, 255, 0.3);
}
button.accent:hover { box-shadow: 0 5px 18px rgba(143, 168, 255, 0.45); background: linear-gradient(145deg, var(--accent-strong), var(--accent)); }

button.mini { padding: 1px 7px; font-size: 11px; border-radius: 6px; }

/* --------------------------------------------------------------- main */

.main { display: flex; flex: 1; min-height: 0; }

.timeline-wrap {
  flex: 1;
  overflow: auto;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 200 200'%3E%3Cg fill='none' stroke='%238FA8FF' opacity='0.05'%3E%3Ccircle cx='100' cy='100' r='22' stroke-width='5'/%3E%3Ccircle cx='100' cy='100' r='48' stroke-width='3.5'/%3E%3Ccircle cx='100' cy='100' r='76' stroke-width='2.5'/%3E%3Ccircle cx='100' cy='100' r='97' stroke-width='1.5'/%3E%3C/g%3E%3Ccircle cx='100' cy='100' r='9' fill='%238FA8FF' opacity='0.06'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right -60px bottom -60px;
  background-size: 420px;
}
canvas.timeline { display: block; width: 100%; }

/* ---------------------------------------------------------- side panel */

.side {
  width: 330px;
  overflow-y: auto;
  background: rgba(15, 21, 42, 0.6);
  border-left: 1px solid var(--border-soft);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.side section {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-lg);
  padding: 14px 16px;
}

.side h3 {
  margin: 0 0 10px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 8px;
}
.side h3::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px rgba(143, 168, 255, 0.8);
}

.side h4 {
  margin: 10px 0 6px;
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
  letter-spacing: 0.06em;
}

.field {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 6px 0;
  font-size: 12.5px;
  color: var(--muted);
}
.field input, .field select { width: 132px; }
.field-inline {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 4px 12px 4px 0;
  font-size: 12.5px;
  color: var(--muted);
}

input, select {
  background: rgba(9, 13, 28, 0.7);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 6px 9px;
  font: 400 12.5px "Outfit", system-ui, sans-serif;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input:focus, select:focus {
  outline: none;
  border-color: var(--accent-dim);
  box-shadow: 0 0 0 3px rgba(143, 168, 255, 0.15);
}
input[type="checkbox"] { accent-color: var(--accent); width: 15px; height: 15px; }

.row { display: flex; gap: 8px; align-items: center; margin: 8px 0 2px; }

.layer-list { display: flex; flex-direction: column; gap: 3px; }
.layer-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 7px 10px;
  border-radius: var(--r-sm);
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 0.12s ease, border-color 0.12s ease;
  font-size: 12.5px;
}
.layer-row:hover { background: rgba(143, 168, 255, 0.07); }
.layer-row.sel {
  background: rgba(143, 168, 255, 0.12);
  border-color: rgba(143, 168, 255, 0.35);
}

.errors {
  background: rgba(255, 128, 144, 0.08);
  border: 1px solid rgba(255, 128, 144, 0.4);
  border-radius: var(--r-md);
  color: #ffc2cb;
  padding: 10px 12px;
  font-size: 12px;
  white-space: pre-wrap;
}

/* cloud group in top bar */

.cloud-group {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  padding-left: 14px;
  border-left: 1px solid var(--border-soft);
}

.account-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 12px 4px 5px;
  border-radius: 999px;
  background: rgba(143, 168, 255, 0.07);
}
.account-chip .avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: linear-gradient(145deg, var(--accent), var(--accent-dim));
  color: #0a1026;
  font-weight: 600;
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.account-chip .account-name { font-weight: 500; }
.account-chip .caret { color: var(--muted); font-size: 10px; }
.account-chip .plan-pill {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  padding: 2px 8px;
  border-radius: 999px;
  color: var(--accent);
  background: rgba(143, 168, 255, 0.14);
}
.menu-caption {
  padding: 8px 12px 4px;
  font-size: 11.5px;
  color: var(--muted);
}

/* ------------------------------------------------------------- sidebar */

.sidebar {
  width: 250px;
  background: rgba(13, 18, 38, 0.65);
  border-right: 1px solid var(--border-soft);
  padding: 14px 12px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.lib-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 4px 4px;
}
.lib-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--muted);
}

.lib-save {
  width: 100%;
  text-align: left;
  padding: 9px 12px;
  border-style: dashed;
  color: var(--muted);
  background: transparent;
}
.lib-save:hover { color: var(--text); }

.lib-empty {
  font-size: 12px;
  color: var(--muted);
  padding: 8px 6px;
  margin: 0;
}

.lib-signin {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-lg);
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.lib-signin p { margin: 0; font-size: 12.5px; color: var(--muted); line-height: 1.55; }

.lib-item {
  width: 100%;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 11px 12px;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-md);
  transition: border-color 0.15s ease, transform 0.12s ease, background 0.15s ease;
}
.lib-item:hover {
  border-color: var(--accent-dim);
  background: rgba(143, 168, 255, 0.06);
  transform: translateY(-1px);
}
.lib-item-name { font-size: 13px; font-weight: 500; }
.lib-row { position: relative; }
.lib-row .lib-item-name { padding-right: 20px; }
.lib-del {
  position: absolute;
  top: 7px;
  right: 7px;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s ease, color 0.15s ease, background 0.15s ease;
}
.lib-row:hover .lib-del,
.lib-del:focus-visible { opacity: 1; }
.lib-del:hover { color: #ffd6dc; background: rgba(255, 128, 144, 0.14); }
.lib-item-meta {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 11px;
  color: var(--muted);
}
.goal-chip {
  display: inline-block;
  padding: 1.5px 8px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.05em;
  color: var(--chip);
  background: color-mix(in srgb, var(--chip) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--chip) 35%, transparent);
}

/* --------------------------------------------------------------- toasts */

#toasts {
  position: fixed;
  bottom: 18px;
  right: 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 100;
  max-width: 380px;
}
.toast {
  background: var(--raised);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--r-md);
  box-shadow: var(--shadow);
  padding: 10px 14px;
  font-size: 12.5px;
  white-space: pre-line;
  animation: toast-in 0.2s ease;
}
.toast.error { border-left-color: var(--error); color: #ffd6dc; }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}
.toast.out { opacity: 0; transition: opacity 0.4s ease; }

/* --------------------------------------------------------------- modal */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(5, 8, 18, 0.7);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 90;
}
.modal-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
  padding: 22px;
  min-width: 340px;
  max-width: 500px;
  max-height: 70vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.modal-box h3 { margin: 0 0 8px; font-size: 15px; font-weight: 600; }
.modal-row { text-align: left; padding: 10px 12px; }

.field-hint {
  font-size: 10.5px;
  color: var(--muted);
  opacity: 0.8;
  margin: 2px 0 6px;
  line-height: 1.5;
}

/* solfeggio picker */
.solf-box { width: 420px; }
.solf-sub { margin: 0 0 10px; font-size: 12.5px; color: var(--muted); }
.solf-hint { margin: 2px 0 10px; font-size: 11.5px; color: var(--muted); min-height: 15px; }
.solf-chips { display: flex; gap: 8px; margin-bottom: 8px; }
.solf-chip {
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  font: 500 12.5px "Outfit", system-ui, sans-serif;
  cursor: pointer;
}
.solf-chip:hover { color: var(--text); border-color: var(--accent-dim); }
.solf-chip.selected {
  background: rgba(111, 217, 201, 0.16);
  border-color: rgba(111, 217, 201, 0.4);
  color: var(--teal);
}
.solf-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.solf-tone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  padding: 16px 8px 14px;
  border-radius: 16px;
  border: 1px solid var(--border-soft);
  background: var(--raised);
  color: var(--text);
  cursor: pointer;
  font-family: "Outfit", system-ui, sans-serif;
  transition: transform 0.15s ease, border-color 0.15s ease;
}
.solf-tone:hover { transform: translateY(-2px); border-color: rgba(111, 217, 201, 0.45); }
.solf-tone .freq { font-size: 21px; font-weight: 700; color: var(--teal); line-height: 1.1; }
.solf-tone .unit { font-size: 10px; color: var(--muted); letter-spacing: 0.08em; }
.solf-tone .label { margin-top: 5px; font-size: 12.5px; font-weight: 600; }

/* scrollbars */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--raised); border-radius: 6px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--border); }
::-webkit-scrollbar-track { background: transparent; }

/* -------------------------------------------------- breathing pacer */

.breath-overlay {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  flex-direction: column;
  align-items: center;
  background:
    radial-gradient(90% 55% at 50% -10%, rgba(111, 217, 201, 0.16), transparent 62%),
    var(--bg);
  animation: breath-rise 0.28s ease;
}
@keyframes breath-rise {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: none; }
}
.breath-head {
  width: min(720px, 100%);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px 0;
}
.breath-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.3em;
  color: var(--muted);
}
.breath-voice.on { color: var(--teal); }
.breath-chips {
  display: flex;
  gap: 8px;
  margin-top: 14px;
}
.breath-chips .solf-chip.selected {
  background: rgba(111, 217, 201, 0.16);
  border-color: rgba(111, 217, 201, 0.5);
  color: var(--teal);
}
.breath-orb {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 0;
}
.breath-orb svg { width: min(46vh, 82vw, 420px); height: auto; }
.breath-readout { text-align: center; }
.breath-phase { font-size: 22px; font-weight: 600; }
.breath-count { margin-top: 2px; font-size: 17px; color: var(--teal); font-weight: 600; }
.breath-cycles { margin-top: 4px; font-size: 12px; color: var(--muted); }
.breath-controls {
  display: flex;
  align-items: center;
  gap: 22px;
  padding: 18px 0 26px;
}
.breath-play {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  border: none;
  background: var(--teal);
  color: #0b1020;
  display: flex;
  align-items: center;
  justify-content: center;
}
.breath-play:hover { background: #85e4d5; border: none; }
.breath-play svg { width: 22px; height: 22px; }

.menu-item.danger { color: #f2969b; }
.menu-item.danger:hover { background: rgba(242, 150, 155, 0.12); }

.modal-note { font-size: 13px; color: var(--muted); line-height: 1.55; margin: 0 0 10px; }
.modal-note b { color: var(--text); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }
.danger-solid {
  background: #b3454c;
  border-color: #b3454c;
  color: #fff;
}
.danger-solid:hover { background: #c9545c; border-color: #c9545c; }
