:root {
  --ink: #18211f;
  --muted: #69736f;
  --paper: #fffdf7;
  --soft: rgba(255, 253, 247, 0.82);
  --line: rgba(24, 33, 31, 0.13);
  --green: #315f50;
  --green-2: #7aa37e;
  --rose: #c96773;
  --gold: #d4a84f;
  --blue: #668fa5;
  --plum: #7a6a9f;
  --shadow: 0 24px 70px rgba(22, 31, 29, 0.18);
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  overflow: hidden;
  overflow-x: hidden;
  background: #e6ece4;
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

canvas {
  display: block;
}

.pente-shell {
  position: relative;
  display: grid;
  width: 100%;
  height: 100vh;
  grid-template-columns: minmax(260px, 320px) minmax(420px, 1fr) minmax(270px, 340px);
  grid-template-rows: 72px minmax(0, 1fr);
  gap: 14px;
  padding: 14px;
  overflow: hidden;
}

#garden {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  background:
    radial-gradient(circle at 24% 20%, rgba(122, 163, 126, 0.28), transparent 28%),
    radial-gradient(circle at 78% 18%, rgba(102, 143, 165, 0.24), transparent 25%),
    linear-gradient(135deg, #eef2e7, #dce8df 48%, #ece8d9);
}

.topbar,
.left-rail,
.desk,
.right-rail {
  position: relative;
  z-index: 2;
  min-width: 0;
}

.topbar {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  border: 1px solid rgba(255, 255, 255, 0.74);
  border-radius: 8px;
  background: rgba(255, 253, 247, 0.72);
  box-shadow: 0 16px 42px rgba(22, 31, 29, 0.1);
  backdrop-filter: blur(18px);
  padding: 10px;
}

.home-link {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  color: var(--ink);
  text-decoration: none;
}

.mark,
.guide-face {
  display: grid;
  place-items: center;
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(49, 95, 80, 0.95), rgba(122, 106, 159, 0.86)),
    #315f50;
  color: white;
  font-weight: 950;
}

.mark {
  width: 42px;
  height: 42px;
  font-size: 1.3rem;
}

strong,
small,
span {
  overflow-wrap: anywhere;
}

.home-link strong {
  display: block;
  font-size: 1.05rem;
}

.home-link small {
  display: block;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
}

.mode-tabs {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(116px, 1fr);
  gap: 8px;
  overflow-x: auto;
  min-width: 0;
  max-width: 100%;
  scrollbar-width: thin;
}

.mode-tabs button,
.section-title button,
.secondary,
.primary,
.icon-btn {
  min-height: 40px;
  border-radius: 8px;
  font-weight: 900;
  transition:
    transform 160ms ease,
    background 160ms ease,
    box-shadow 160ms ease;
}

.mode-tabs button {
  padding: 0 12px;
  background: rgba(255, 255, 255, 0.62);
  color: var(--green);
  outline: 1px solid rgba(49, 95, 80, 0.14);
  white-space: nowrap;
}

.mode-tabs button.is-active,
.primary {
  background: var(--green);
  color: white;
  box-shadow: 0 14px 30px rgba(49, 95, 80, 0.24);
}

.top-actions,
.timer-actions,
.footer-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.icon-btn {
  display: grid;
  width: 42px;
  min-width: 42px;
  place-items: center;
  background: rgba(255, 255, 255, 0.7);
  color: var(--green);
  outline: 1px solid rgba(49, 95, 80, 0.16);
}

.icon-btn.danger {
  color: #963d47;
}

button:hover {
  transform: translateY(-1px);
}

.left-rail,
.right-rail {
  display: grid;
  min-height: 0;
  gap: 12px;
}

.left-rail {
  grid-template-rows: auto auto minmax(0, 1fr);
}

.right-rail {
  grid-template-rows: auto auto minmax(0, 1fr);
}

.guide,
.protocol,
.prompt-box,
.desk,
.map-card,
.alchemy,
.archive,
.modal {
  min-width: 0;
  border: 1px solid rgba(255, 255, 255, 0.74);
  border-radius: 8px;
  background: var(--soft);
  box-shadow: 0 18px 52px rgba(22, 31, 29, 0.13);
  backdrop-filter: blur(20px);
}

.guide {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr);
  gap: 12px;
  padding: 12px;
}

.guide-face {
  width: 64px;
  height: 64px;
  align-self: start;
  overflow: hidden;
}

.guide-face span {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #fffdf7;
  box-shadow:
    -14px 18px 0 -5px rgba(255, 253, 247, 0.78),
    14px 18px 0 -5px rgba(255, 253, 247, 0.78),
    0 30px 0 10px rgba(255, 253, 247, 0.22);
}

.kicker {
  margin: 0 0 8px;
  color: var(--green);
  font-size: 0.72rem;
  font-weight: 950;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 6px;
  font-size: clamp(2.3rem, 5vw, 4.5rem);
  line-height: 0.9;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 8px;
  font-size: clamp(1.25rem, 2.2vw, 2rem);
  line-height: 1.08;
  letter-spacing: 0;
}

p {
  color: var(--muted);
  line-height: 1.54;
}

.protocol,
.prompt-box,
.map-card,
.alchemy,
.archive {
  padding: 14px;
}

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

.section-title span {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 950;
  text-transform: uppercase;
}

.section-title button,
.secondary {
  padding: 0 12px;
  background: rgba(255, 255, 255, 0.66);
  color: var(--green);
  outline: 1px solid rgba(49, 95, 80, 0.16);
}

.primary {
  padding: 0 16px;
}

.days {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.day {
  min-height: 68px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.58);
  outline: 1px solid rgba(49, 95, 80, 0.12);
  padding: 8px;
}

.day strong {
  display: block;
  font-size: 1.15rem;
}

.day span {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
}

.day.is-done {
  background: rgba(122, 163, 126, 0.25);
}

.microcopy {
  margin: 12px 0 0;
  font-size: 0.88rem;
}

.prompt-box {
  min-height: 0;
  overflow: auto;
}

.prompt-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.prompt-tags span {
  border-radius: 999px;
  padding: 6px 9px;
  background: rgba(49, 95, 80, 0.1);
  color: var(--green);
  font-size: 0.74rem;
  font-weight: 900;
}

.desk {
  display: grid;
  min-height: 0;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  padding: 16px;
}

.session-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: start;
  border-bottom: 1px solid var(--line);
  padding-bottom: 12px;
}

.timer {
  display: grid;
  gap: 8px;
  justify-items: end;
}

.timer > strong {
  font-variant-numeric: tabular-nums;
  font-size: clamp(1.6rem, 4vw, 3rem);
  line-height: 1;
}

.intensity-row {
  display: grid;
  grid-template-columns: 1fr 1fr 92px;
  gap: 10px;
  padding: 12px 0;
}

.intensity-row label,
.alchemy label {
  display: grid;
  gap: 6px;
}

label span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
}

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

select,
input[type="text"] {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--ink);
  padding: 0 10px;
}

.intensity-row strong {
  color: var(--green);
}

textarea {
  width: 100%;
  min-height: 0;
  resize: none;
  border: 1px solid rgba(49, 95, 80, 0.15);
  border-radius: 8px;
  outline: 0;
  background:
    linear-gradient(rgba(255, 253, 247, 0.94), rgba(255, 253, 247, 0.94)),
    repeating-linear-gradient(transparent 0 35px, rgba(49, 95, 80, 0.09) 36px);
  color: var(--ink);
  padding: 22px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1rem, 1.3vw, 1.18rem);
  line-height: 1.82;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

textarea:focus {
  border-color: rgba(49, 95, 80, 0.38);
  box-shadow: 0 0 0 4px rgba(49, 95, 80, 0.08);
}

.writer-footer {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding-top: 12px;
}

.readouts {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.readouts span {
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.62);
  color: var(--muted);
  padding: 8px 10px;
  font-size: 0.82rem;
  font-weight: 800;
}

.readouts strong {
  color: var(--ink);
}

.map-grid {
  display: grid;
  gap: 8px;
}

.map-item {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  gap: 8px;
  align-items: center;
  min-height: 44px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.56);
  outline: 1px solid rgba(49, 95, 80, 0.1);
  padding: 8px;
}

.map-dot {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: rgba(105, 115, 111, 0.22);
}

.map-item.is-on .map-dot {
  background: var(--green);
  box-shadow: 0 0 0 5px rgba(49, 95, 80, 0.11);
}

.map-item span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
}

.alchemy {
  display: grid;
  gap: 10px;
}

.archive {
  min-height: 0;
  overflow: hidden;
}

.entries {
  display: grid;
  max-height: 100%;
  gap: 8px;
  overflow: auto;
  padding-right: 2px;
}

.entry {
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.58);
  outline: 1px solid rgba(49, 95, 80, 0.1);
  padding: 10px;
}

.entry strong {
  display: block;
  margin-bottom: 4px;
}

.entry p {
  display: -webkit-box;
  margin: 0;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  font-size: 0.84rem;
}

.modal {
  width: min(560px, calc(100vw - 28px));
  border: 0;
  padding: 24px;
  color: var(--ink);
}

.modal::backdrop {
  background: rgba(20, 30, 27, 0.36);
  backdrop-filter: blur(8px);
}

.close {
  position: absolute;
  top: 10px;
  right: 10px;
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.74);
  color: var(--green);
  font-weight: 950;
}

@media (max-width: 1120px) {
  body {
    overflow: auto;
    overflow-x: hidden;
  }

  .pente-shell {
    min-height: 100vh;
    height: auto;
    grid-template-columns: 1fr;
    grid-template-rows: auto;
    overflow: visible;
  }

  .topbar {
    position: sticky;
    top: 10px;
    z-index: 5;
    grid-template-columns: 1fr auto;
  }

  .mode-tabs {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  .desk {
    min-height: 72vh;
  }

  #garden {
    position: fixed;
  }
}

@media (max-width: 680px) {
  .pente-shell {
    gap: 10px;
    padding: 10px;
  }

  .topbar,
  .session-head,
  .writer-footer {
    display: grid;
    grid-template-columns: 1fr;
  }

  .topbar,
  .left-rail,
  .desk,
  .right-rail {
    width: min(100%, calc(100vw - 20px));
    max-width: calc(100vw - 20px);
  }

  .mode-tabs {
    display: flex;
  }

  .mode-tabs button {
    flex: 0 0 116px;
  }

  .top-actions,
  .timer,
  .footer-actions {
    justify-self: start;
  }

  .intensity-row {
    grid-template-columns: 1fr;
  }

  .days {
    grid-template-columns: repeat(2, 1fr);
  }
}
