:root {
  --ink: #193e34;
  --paper: #fffaf0;
  --paper-deep: #f9ecd7;
  --forest: #247252;
  --moss: #698653;
  --rose: #d85c73;
  --lavender: #936fb0;
  --gold: #e3ac38;
  --line: rgba(25, 62, 52, .16);
  --display: "Italiana", Georgia, serif;
  --sans: "DM Sans", Arial, sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: linear-gradient(145deg, #fffaf0, #fff2d9 48%, #f2f8df); color: var(--ink); font-family: var(--sans); }
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; text-decoration: none; }
button { cursor: pointer; }

.admin-header { position: sticky; z-index: 10; top: 0; min-height: 76px; padding: .9rem clamp(1rem, 4vw, 4rem); display: flex; align-items: center; justify-content: space-between; gap: 1rem; border-bottom: 1px solid var(--line); background: rgba(255,250,240,.9); backdrop-filter: blur(18px); }
.brand { display: inline-flex; align-items: center; gap: .7rem; font-family: var(--display); font-size: 1.25rem; }
.brand svg { width: 24px; fill: none; stroke: currentColor; stroke-width: 1.15; }
.header-actions { display: flex; align-items: center; gap: .8rem; }
.save-state { font-size: .75rem; color: rgba(25,62,52,.62); }
.ghost-button, .save-button { border-radius: 999px; padding: .72rem 1rem; border: 1px solid var(--line); background: rgba(255,255,255,.62); color: var(--ink); font-weight: 600; font-size: .82rem; }
.save-button { border-color: var(--rose); background: var(--rose); color: white; box-shadow: 0 8px 22px rgba(216,92,115,.2); }
.save-button:disabled { opacity: .45; cursor: default; box-shadow: none; }
.ghost-button.dark { background: transparent; }

main { padding: 0 clamp(1rem, 4vw, 4rem) 5rem; }
.intro { max-width: 1450px; margin: auto; padding: clamp(3.5rem, 7vw, 7rem) 0 3.2rem; display: grid; grid-template-columns: 1.25fr .75fr; align-items: end; gap: 3rem; }
.eyebrow, .label { margin: 0 0 .8rem; color: var(--rose); text-transform: uppercase; letter-spacing: .16em; font-weight: 600; font-size: .7rem; }
h1, h2, strong { font-family: var(--display); font-weight: 400; }
h1 { margin: 0; font-size: clamp(3.5rem, 7vw, 7rem); line-height: .88; letter-spacing: -.03em; }
h1 em { color: var(--rose); font-style: normal; }
.intro > p { max-width: 470px; margin: 0 0 .5rem; color: rgba(25,62,52,.68); font-size: 1.05rem; }

.workspace { max-width: 1450px; margin: auto; min-height: 850px; display: grid; grid-template-columns: 330px minmax(0,1fr); border: 1px solid var(--line); border-radius: 28px; overflow: hidden; background: rgba(255,255,255,.62); box-shadow: 0 30px 80px rgba(56,74,42,.12); }
.poem-sidebar { padding: 1.6rem; border-right: 1px solid var(--line); background: rgba(246,250,230,.66); }
.sidebar-heading, .form-heading { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.sidebar-heading h2, .form-heading h2 { margin: 0; font-size: 2.1rem; line-height: 1; }
.icon-button { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 50%; border: 0; color: white; background: var(--forest); font-size: 1.4rem; }
.poem-list { display: grid; gap: .55rem; margin-top: 1.7rem; }
.poem-row { display: grid; grid-template-columns: 1fr auto; gap: .5rem; align-items: center; padding: .65rem .7rem .65rem .9rem; border: 1px solid transparent; border-radius: 14px; background: rgba(255,255,255,.58); }
.poem-row.active { border-color: rgba(216,92,115,.38); background: white; box-shadow: 0 8px 20px rgba(44,67,42,.08); }
.poem-select { padding: 0; text-align: left; border: 0; background: none; color: inherit; }
.poem-select b, .poem-select small { display: block; }
.poem-select b { margin-bottom: .1rem; font-size: .9rem; }
.poem-select small { color: rgba(25,62,52,.56); }
.order-buttons { display: flex; }
.order-buttons button { width: 27px; height: 30px; border: 0; color: var(--moss); background: transparent; border-radius: 8px; }
.order-buttons button:hover { background: var(--paper-deep); }
.order-buttons button:disabled { opacity: .25; }
.sidebar-help { margin: 1.25rem .3rem 0; color: rgba(25,62,52,.52); font-size: .75rem; }

.editor-panel { min-width: 0; background: rgba(255,253,248,.82); }
.panel-tabs { display: flex; gap: 1.6rem; padding: 0 clamp(1.4rem, 5vw, 4.5rem); border-bottom: 1px solid var(--line); }
.panel-tab { padding: 1.35rem .15rem 1.1rem; border: 0; border-bottom: 2px solid transparent; background: none; color: rgba(25,62,52,.58); }
.panel-tab.active { color: var(--ink); border-color: var(--rose); }
.editor-form, .appearance-panel, .site-text-panel { padding: clamp(1.8rem, 5vw, 4.5rem); }
.form-heading { margin-bottom: 2.5rem; }
.delete-button { padding: .55rem 0; border: 0; border-bottom: 1px solid rgba(168,50,70,.32); color: #a83246; background: none; font-size: .78rem; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1.2rem; }
label { display: grid; gap: .5rem; margin-bottom: 1.2rem; color: rgba(25,62,52,.72); font-size: .76rem; font-weight: 600; letter-spacing: .04em; }
input, select, textarea { width: 100%; border: 1px solid var(--line); border-radius: 12px; padding: .82rem .9rem; outline: none; background: rgba(255,255,255,.74); color: var(--ink); font-size: .95rem; font-weight: 400; letter-spacing: 0; }
input:focus, select:focus, textarea:focus { border-color: rgba(216,92,115,.66); box-shadow: 0 0 0 3px rgba(216,92,115,.1); }
textarea { resize: vertical; line-height: 1.55; }
.poem-textarea { min-height: 450px; font-family: Georgia, serif; font-size: 1.03rem; }
label small { color: rgba(25,62,52,.5); font-weight: 400; }

.text-section { margin-top: 2.2rem; padding-top: 2rem; border-top: 1px solid var(--line); }
.text-section:first-child { margin-top: 1.2rem; }
.text-section h3 { margin: 0 0 1.2rem; font-family: var(--display); font-size: 1.65rem; font-weight: 400; }
.site-text-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 0 1.2rem; }
.site-text-grid label.long { grid-column: 1 / -1; }
.site-text-grid textarea { min-height: 92px; }

.panel-intro { max-width: 630px; color: rgba(25,62,52,.65); }
.color-grid { margin: 2rem 0; display: grid; grid-template-columns: repeat(3, minmax(150px,1fr)); gap: .9rem; }
.color-field { margin: 0; display: flex; align-items: center; justify-content: space-between; gap: .8rem; padding: .85rem 1rem; border: 1px solid var(--line); border-radius: 14px; background: rgba(255,255,255,.65); }
.color-field span { font-size: .78rem; }
.color-field input { width: 42px; height: 42px; padding: 3px; border-radius: 50%; cursor: pointer; }
.palette-preview { min-height: 320px; padding: 3rem; border-radius: 20px; display: flex; flex-direction: column; align-items: flex-start; justify-content: center; background: var(--preview-paper, #fffaf0); color: var(--preview-ink, #193e34); overflow: hidden; position: relative; }
.palette-preview::after { content: "✿"; position: absolute; right: 7%; color: var(--preview-gold, #e3ac38); font-size: 11rem; opacity: .24; }
.palette-preview span { position: relative; z-index: 1; color: var(--preview-rose, #d85c73); text-transform: uppercase; letter-spacing: .14em; font-size: .7rem; }
.palette-preview strong { position: relative; z-index: 1; max-width: 560px; font-size: clamp(2.8rem,5vw,5rem); line-height: .92; }
.palette-preview button { position: relative; z-index: 1; margin-top: 1.5rem; padding: .75rem 1rem; border: 0; border-radius: 999px; background: var(--preview-rose, #d85c73); color: white; }

.error-card { max-width: 680px; margin: 3rem auto; padding: 3rem; border: 1px solid var(--line); border-radius: 24px; text-align: center; background: rgba(255,255,255,.7); }
.error-card h2 { margin: 0; font-size: 2.7rem; }
.error-card p:not(.eyebrow) { color: rgba(25,62,52,.65); }
.toast { position: fixed; z-index: 20; left: 50%; bottom: 1.5rem; transform: translate(-50%, 130%); opacity: 0; padding: .8rem 1.1rem; border-radius: 999px; background: var(--forest); color: white; box-shadow: 0 12px 30px rgba(0,0,0,.18); transition: .3s ease; font-size: .84rem; }
.toast.show { transform: translate(-50%,0); opacity: 1; }

@media (max-width: 900px) {
  .save-state { display: none; }
  .intro { grid-template-columns: 1fr; gap: 1.2rem; }
  .workspace { grid-template-columns: 1fr; }
  .poem-sidebar { border-right: 0; border-bottom: 1px solid var(--line); }
  .poem-list { display: flex; overflow-x: auto; padding-bottom: .5rem; }
  .poem-row { min-width: 230px; }
  .color-grid { grid-template-columns: repeat(2, minmax(150px,1fr)); }
}
@media (max-width: 620px) {
  .admin-header { align-items: flex-start; }
  .brand span { display: none; }
  .ghost-button { display: none; }
  .field-row { grid-template-columns: 1fr; gap: 0; }
  .editor-form, .appearance-panel, .site-text-panel { padding: 1.4rem; }
  .site-text-grid { grid-template-columns: 1fr; }
  .site-text-grid label.long { grid-column: auto; }
  .color-grid { grid-template-columns: 1fr; }
  .form-heading { align-items: flex-start; }
  .palette-preview { min-height: 260px; padding: 1.5rem; }
}
