:root {
  color-scheme: light;
  --ink: #17323b;
  --ink-soft: #526a72;
  --navy: #173f4d;
  --teal: #16889a;
  --teal-dark: #0d6978;
  --teal-pale: #e8f6f7;
  --cream: #fbfaf6;
  --surface: #ffffff;
  --line: #dbe5e6;
  --danger: #a94343;
  --danger-pale: #fff1f1;
  --shadow: 0 18px 48px rgba(24, 63, 77, 0.12);
  --radius: 18px;
  --font: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html { min-width: 320px; background: var(--cream); }

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 8%, rgba(22, 136, 154, 0.10), transparent 32rem),
    var(--cream);
  font-family: var(--font);
  line-height: 1.5;
}

button, input, textarea { font: inherit; }

button { cursor: pointer; }

.skip-link {
  position: fixed;
  left: 1rem;
  top: -5rem;
  z-index: 1000;
  padding: .75rem 1rem;
  color: white;
  background: var(--navy);
  border-radius: .5rem;
}

.skip-link:focus { top: 1rem; }

.site-header {
  min-height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .8rem clamp(1rem, 4vw, 4rem);
  background: rgba(255, 255, 255, .91);
  border-bottom: 1px solid rgba(219, 229, 230, .9);
  backdrop-filter: blur(14px);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: .75rem;
  color: var(--ink);
  text-decoration: none;
}

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  color: white;
  background: linear-gradient(145deg, var(--teal), var(--navy));
  border-radius: 12px;
  font: 700 1.25rem Georgia, serif;
}

.brand strong, .brand small { display: block; }
.brand strong { font-size: 1rem; letter-spacing: -.01em; }
.brand small { color: var(--ink-soft); font-size: .72rem; letter-spacing: .06em; text-transform: uppercase; }

.account-actions { display: flex; align-items: center; gap: .8rem; }
.account-email { color: var(--ink-soft); font-size: .84rem; max-width: 18rem; overflow: hidden; text-overflow: ellipsis; }

main { min-height: calc(100vh - 76px); }

.auth-layout {
  width: min(1120px, calc(100% - 2rem));
  min-height: calc(100vh - 76px);
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(320px, .85fr);
  align-items: center;
  gap: clamp(2rem, 8vw, 7rem);
  padding: 4rem 0 6rem;
}

.auth-intro h1, .studio-heading h1 {
  margin: .25rem 0 1rem;
  color: var(--navy);
  font: 600 clamp(2.6rem, 6vw, 5.3rem)/.98 Georgia, "Times New Roman", serif;
  letter-spacing: -.05em;
}

.studio-heading h1 { font-size: clamp(2.3rem, 4vw, 3.8rem); }

.eyebrow {
  margin: 0;
  color: var(--teal-dark);
  font-size: .75rem;
  font-weight: 800;
  letter-spacing: .13em;
  text-transform: uppercase;
}

.lede { max-width: 42rem; color: var(--ink-soft); font-size: 1.15rem; }
.subtle { color: var(--ink-soft); }

.boundary-card {
  max-width: 38rem;
  margin-top: 2rem;
  padding: 1.1rem 1.25rem;
  background: var(--teal-pale);
  border: 1px solid #c7e9eb;
  border-radius: 14px;
}

.boundary-card p { margin: .35rem 0 0; color: var(--ink-soft); }

.auth-card, .editor-card {
  background: var(--surface);
  border: 1px solid rgba(219, 229, 230, .95);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.auth-card { padding: clamp(1.5rem, 4vw, 2.5rem); }
.auth-card h2 { margin: .45rem 0 .4rem; font-size: 1.65rem; }
.auth-card .subtle { margin: 0 0 1.6rem; }

label, .search-label { display: block; margin: 1rem 0 .4rem; color: var(--ink); font-size: .86rem; font-weight: 700; }
.label-hint { color: var(--ink-soft); font-weight: 400; }

input, textarea {
  width: 100%;
  border: 1px solid #cbd9dc;
  border-radius: 10px;
  padding: .78rem .9rem;
  color: var(--ink);
  background: white;
  transition: border-color .15s, box-shadow .15s;
}

textarea { resize: vertical; min-height: 7rem; }

input:focus, textarea:focus {
  outline: none;
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(22, 136, 154, .16);
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: .68rem 1rem;
  border: 1px solid transparent;
  border-radius: 10px;
  font-weight: 750;
}

.button:focus-visible { outline: 3px solid rgba(22, 136, 154, .3); outline-offset: 2px; }
.button:disabled { cursor: wait; opacity: .6; }
.button-full { width: 100%; margin-top: 1.2rem; }
.button-primary { color: white; background: var(--teal-dark); }
.button-primary:hover { background: var(--navy); }
.button-secondary { color: var(--navy); background: white; border-color: #b9cccf; }
.button-secondary:hover, .button-quiet:hover { background: var(--teal-pale); }
.button-quiet { color: var(--navy); background: transparent; border-color: var(--line); }
.button-danger { color: var(--danger); background: var(--danger-pale); border-color: #f3cece; }

.divider { display: flex; align-items: center; gap: .8rem; margin: 1.3rem 0 .1rem; color: #87999e; font-size: .78rem; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.form-status { min-height: 1.4rem; margin: .8rem 0 0; color: var(--danger); font-size: .84rem; }

.studio { width: min(1440px, calc(100% - 2rem)); margin: 0 auto; padding: 1.4rem 0 4rem; }

.preview-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .7rem;
  margin-bottom: 2rem;
  padding: .65rem 1rem;
  color: #694d17;
  background: #fff6d9;
  border: 1px solid #ead796;
  border-radius: 10px;
  font-size: .84rem;
}

.studio-heading { display: flex; align-items: end; justify-content: space-between; gap: 1rem; margin-bottom: 2rem; padding: 0 .2rem; }
.studio-heading h1 { margin-bottom: .45rem; }
.studio-heading .subtle { margin: 0; }

.studio-grid { display: grid; grid-template-columns: 310px minmax(0, 1fr); gap: 1.2rem; align-items: start; }

.template-sidebar {
  padding: 1rem;
  background: rgba(255, 255, 255, .72);
  border: 1px solid var(--line);
  border-radius: 16px;
}

.search-label { margin-top: 0; }
.search-input { background: white; }
.template-list { display: grid; gap: .55rem; margin-top: 1rem; }

.template-item {
  width: 100%;
  padding: .85rem;
  text-align: left;
  color: var(--ink);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 11px;
}

.template-item:hover { background: white; border-color: var(--line); }
.template-item[aria-current="true"] { background: var(--teal-pale); border-color: #b9dfe2; }
.template-item strong, .template-item small { display: block; }
.template-item strong { margin-bottom: .25rem; }
.template-item small { color: var(--ink-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-empty { padding: 1rem .4rem; color: var(--ink-soft); font-size: .86rem; }

.editor-card { min-height: 620px; padding: clamp(1.2rem, 3vw, 2.2rem); }
.empty-editor { min-height: 540px; display: grid; place-content: center; justify-items: center; text-align: center; color: var(--ink-soft); }
.empty-editor h2 { margin: 1rem 0 .3rem; color: var(--ink); }
.empty-editor p { margin: 0; }
.empty-icon { width: 64px; height: 64px; display: grid; place-items: center; color: var(--teal-dark); background: var(--teal-pale); border-radius: 18px; font: 600 2rem Georgia, serif; }

.editor-header { display: flex; justify-content: space-between; align-items: start; gap: 1rem; margin-bottom: 1.6rem; padding-bottom: 1rem; border-bottom: 1px solid var(--line); }
.editor-header h2 { margin: .2rem 0 0; font-size: 1.55rem; }
.editor-actions { display: flex; gap: .5rem; }
.section-field { margin-top: 1.2rem; padding-top: .15rem; border-top: 1px solid #eef2f2; }
.save-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-top: 1.5rem; }
.save-row .form-status { color: var(--teal-dark); }

@media (max-width: 850px) {
  .auth-layout { grid-template-columns: 1fr; gap: 2rem; align-items: start; padding-top: 3rem; }
  .auth-intro h1 { font-size: clamp(2.7rem, 12vw, 4.5rem); }
  .studio-grid { grid-template-columns: 1fr; }
  .template-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .account-email { display: none; }
}

@media (max-width: 560px) {
  .site-header { min-height: 68px; }
  .auth-layout { width: min(100% - 1.2rem, 1120px); }
  .studio { width: min(100% - 1rem, 1440px); }
  .preview-banner, .studio-heading, .editor-header, .save-row { align-items: stretch; flex-direction: column; }
  .studio-heading .button { width: 100%; }
  .template-list { grid-template-columns: 1fr; }
  .editor-actions { display: grid; grid-template-columns: 1fr 1fr; }
}
