:root {
  --ink: #17211f;
  --muted: #61706c;
  --paper: #f8f3e8;
  --panel: rgba(252, 248, 238, 0.88);
  --line: rgba(23, 33, 31, 0.14);
  --shadow: 0 24px 70px rgba(15, 27, 25, 0.2);
  --green: #34685a;
  --teal: #2f7b83;
  --rose: #c96265;
  --gold: #c9923e;
  --blue: #557da8;
  --plum: #8a668d;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
}

body {
  margin: 0;
  overflow: hidden;
  background:
    linear-gradient(120deg, rgba(52, 104, 90, 0.22), transparent 42%),
    linear-gradient(310deg, rgba(201, 146, 62, 0.2), transparent 44%),
    #e4ece2;
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

canvas {
  display: block;
}

.studio-shell {
  display: grid;
  grid-template-rows: 72px 1fr;
  width: 100vw;
  height: 100vh;
  min-width: 320px;
}

.topbar {
  z-index: 5;
  display: grid;
  grid-template-columns: minmax(190px, 260px) minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.72);
  background: rgba(248, 243, 232, 0.74);
  box-shadow: 0 10px 36px rgba(15, 27, 25, 0.09);
  backdrop-filter: blur(18px);
}

.brand {
  display: grid;
  grid-template-columns: 46px 1fr;
  gap: 10px;
  align-items: center;
  min-width: 0;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 46px;
  height: 46px;
  place-items: center;
  border-radius: 8px;
  background:
    radial-gradient(circle at 30% 28%, #fff4cd 0 20%, transparent 22%),
    conic-gradient(from 25deg, var(--green), var(--gold), var(--rose), var(--blue), var(--green));
  color: white;
  font-size: 1.55rem;
  font-weight: 950;
  box-shadow: 0 12px 24px rgba(52, 104, 90, 0.24);
}

.brand strong,
.brand small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand strong {
  font-size: 1.28rem;
}

.brand small {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
}

.mode-tabs,
.quick-actions,
.brush-grid,
.swatches,
.template-grid {
  display: flex;
  gap: 8px;
}

.mode-tabs {
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
}

.mode-tabs::-webkit-scrollbar {
  display: none;
}

.mode-tab,
.icon-btn,
.brush-btn,
.template-btn {
  display: grid;
  place-items: center;
  min-width: 44px;
  height: 44px;
  border-radius: 8px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.64);
  outline: 1px solid rgba(23, 33, 31, 0.12);
  transition:
    transform 160ms ease,
    background 160ms ease,
    box-shadow 160ms ease;
}

.mode-tab {
  grid-template-columns: 26px max-content;
  width: max-content;
  padding: 0 14px 0 10px;
  gap: 8px;
  font-weight: 900;
  white-space: nowrap;
}

.mode-tab.is-active,
.brush-btn.is-active,
.template-btn.is-active {
  background: #17342f;
  color: white;
  box-shadow: 0 14px 28px rgba(23, 52, 47, 0.24);
}

.icon-btn {
  font-size: 1.25rem;
  font-weight: 900;
}

.icon-btn.danger {
  color: #9c2f35;
}

.mode-tab:hover,
.icon-btn:hover,
.brush-btn:hover,
.template-btn:hover {
  transform: translateY(-1px);
}

.workspace {
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr) 286px;
  min-height: 0;
}

.left-panel,
.right-panel {
  display: flex;
  min-height: 0;
  flex-direction: column;
  gap: 12px;
  overflow: auto;
  padding: 12px;
  background: rgba(244, 239, 226, 0.58);
}

.left-panel {
  border-right: 1px solid rgba(255, 255, 255, 0.62);
}

.right-panel {
  border-left: 1px solid rgba(255, 255, 255, 0.62);
}

.panel-section,
.ritual-card,
.breath-meter {
  border: 1px solid rgba(255, 255, 255, 0.68);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 16px 42px rgba(15, 27, 25, 0.1);
  backdrop-filter: blur(18px);
}

.panel-section {
  padding: 14px;
}

.section-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.section-title span,
.eyebrow {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
}

.section-title strong {
  font-size: 0.88rem;
  text-align: right;
}

.brush-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
}

.brush-btn {
  height: 52px;
  font-size: 1.2rem;
}

.swatches {
  flex-wrap: wrap;
}

.swatch {
  width: 34px;
  height: 34px;
  border: 3px solid rgba(255, 255, 255, 0.9);
  border-radius: 50%;
  box-shadow: inset 0 0 0 1px rgba(23, 33, 31, 0.14), 0 8px 16px rgba(23, 33, 31, 0.12);
}

.swatch.is-active {
  outline: 3px solid var(--ink);
  outline-offset: 2px;
}

.color-field {
  display: grid;
  grid-template-columns: 1fr 54px;
  gap: 10px;
  align-items: center;
  margin-top: 12px;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 850;
}

.color-field input {
  width: 54px;
  height: 36px;
  border: 0;
  border-radius: 8px;
  background: transparent;
}

.sliders {
  display: grid;
  gap: 14px;
}

.sliders label,
.toggles label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 820;
}

.sliders label span {
  display: flex;
  justify-content: space-between;
}

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

.canvas-stage {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background:
    radial-gradient(circle at center, rgba(255, 255, 255, 0.4), transparent 58%),
    linear-gradient(135deg, rgba(52, 104, 90, 0.08), rgba(201, 98, 101, 0.08));
}

#paper,
#guide {
  position: absolute;
  top: 50%;
  left: 50%;
  width: min(calc(100% - 36px), calc((100vh - 128px) * 1.454));
  max-height: calc(100% - 36px);
  aspect-ratio: 16 / 11;
  border-radius: 8px;
  transform: translate(-50%, -50%);
  box-shadow: var(--shadow);
}

#paper {
  background: var(--paper);
  cursor: crosshair;
  touch-action: none;
}

#guide {
  pointer-events: none;
}

.ritual-card {
  position: absolute;
  left: 18px;
  bottom: 18px;
  width: min(360px, calc(100% - 36px));
  padding: 14px;
}

.ritual-card span,
.ritual-card strong {
  display: block;
}

.ritual-card span {
  color: var(--green);
  font-size: 0.72rem;
  font-weight: 950;
  text-transform: uppercase;
}

.ritual-card strong {
  margin-top: 3px;
  font-size: 1.05rem;
}

.ritual-card p,
.prompt-box p,
.session-lines p {
  margin: 6px 0 0;
  color: var(--muted);
  line-height: 1.52;
}

.breath-meter {
  position: absolute;
  right: 18px;
  bottom: 18px;
  display: grid;
  grid-template-columns: 40px 1fr;
  gap: 10px;
  align-items: center;
  min-width: 138px;
  padding: 10px 12px;
}

#breath-dot {
  display: block;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: radial-gradient(circle, #fff6d8, var(--gold));
  box-shadow: 0 0 0 0 rgba(201, 146, 62, 0.24);
  animation: breathe 6s ease-in-out infinite;
}

#breath-label {
  font-size: 0.82rem;
  text-transform: uppercase;
}

@keyframes breathe {
  0%,
  100% {
    transform: scale(0.72);
    box-shadow: 0 0 0 0 rgba(201, 146, 62, 0.2);
  }
  50% {
    transform: scale(1.18);
    box-shadow: 0 0 0 18px rgba(201, 146, 62, 0);
  }
}

.prompt-box h1 {
  margin: 4px 0 0;
  font-size: clamp(1.8rem, 3vw, 2.7rem);
  line-height: 0.94;
  letter-spacing: 0;
}

.toggles {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.toggles label {
  grid-template-columns: 18px 1fr;
  align-items: center;
  padding: 8px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.44);
}

.toggles input {
  accent-color: var(--green);
}

.template-grid {
  display: grid;
  grid-template-columns: 1fr;
}

.template-btn {
  grid-template-columns: 32px 1fr;
  justify-items: start;
  width: 100%;
  padding: 0 12px;
  gap: 8px;
  font-weight: 900;
}

.session-lines {
  display: grid;
  gap: 8px;
}

.session-lines p {
  padding: 9px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.42);
  font-size: 0.86rem;
}

@media (max-width: 1080px) {
  .studio-shell {
    grid-template-rows: auto 1fr;
  }

  .topbar {
    grid-template-columns: 1fr auto;
  }

  .mode-tabs {
    grid-column: 1 / -1;
    order: 3;
  }

  .workspace {
    grid-template-columns: 214px minmax(0, 1fr);
  }

  .right-panel {
    display: none;
  }
}

@media (max-width: 760px) {
  body {
    overflow: auto;
  }

  .studio-shell {
    min-height: 100vh;
    height: auto;
  }

  .topbar {
    position: sticky;
    top: 0;
    grid-template-columns: 1fr;
  }

  .quick-actions {
    overflow-x: auto;
  }

  .workspace {
    grid-template-columns: 1fr;
    min-height: 920px;
  }

  .left-panel {
    display: grid;
    grid-template-columns: 1fr;
    border-right: 0;
  }

  .canvas-stage {
    min-height: 72vh;
    order: -1;
  }

  #paper,
  #guide {
    width: calc(100% - 20px);
    max-height: calc(100% - 20px);
  }

  .ritual-card,
  .breath-meter {
    display: none;
  }
}
