:root {
  --ink: #1b2430;
  --ink-soft: #4c5866;
  --paper: #f7f6f3;
  --panel: #ffffff;
  --line: #e2e0da;
  --accent: #2f4b3f;
  --accent-soft: #e8efe9;
  --gold: #a9843f;
  --code-bg: #1b2430;
  --code-text: #e8ece9;
  --shadow: rgba(27, 36, 48, 0.08);
  --radius: 10px;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
}

:root[data-theme="dark"] {
  --ink: #e9e6df;
  --ink-soft: #a5a99f;
  --paper: #16181a;
  --panel: #1f2220;
  --line: #34372f;
  --accent: #6fae8c;
  --accent-soft: #223129;
  --gold: #cca75f;
  --shadow: rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  line-height: 1.5;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ============ SITE HEADER / TOP NAV ============ */

.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

.nav-wrap {
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 2rem;
  position: relative;
}

.brand {
  font-family: var(--serif);
  font-weight: 700;
  font-size: 1.2rem;
  color: var(--ink);
  text-decoration: none;
  letter-spacing: 0.01em;
}

.theme-switcher {
  position: relative;
}

.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel);
  color: var(--ink-soft);
  cursor: pointer;
  line-height: 0;
}

.theme-toggle:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.theme-icon {
  display: none;
}

.theme-toggle[data-active="system"] .theme-icon[data-icon="system"],
.theme-toggle[data-active="light"] .theme-icon[data-icon="light"],
.theme-toggle[data-active="dark"] .theme-icon[data-icon="dark"] {
  display: block;
}

.theme-switcher .theme-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 200;
  min-width: 140px;
  margin: 0;
  padding: 4px;
  list-style: none;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 12px 24px var(--shadow);
  display: none;
}

.theme-switcher.open .theme-menu {
  display: block;
}

.theme-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 0.45rem 0.6rem;
  border: none;
  border-radius: 5px;
  background: transparent;
  color: var(--ink-soft);
  font-family: var(--sans);
  font-size: 0.85rem;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
}

.theme-option:hover {
  background: var(--accent-soft);
  color: var(--accent);
}

.theme-option[aria-checked="true"] {
  color: var(--accent);
}

.theme-option[aria-checked="true"]::after {
  content: "\2713";
}

@media (max-width: 860px) {
  .theme-menu {
    right: 0;
    left: auto;
  }
}

.nav-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  cursor: pointer;
  flex-shrink: 0;
}

.nav-toggle-bar {
  display: block;
  width: 18px;
  height: 2px;
  margin: 0 auto;
  background: var(--ink);
}

.main-nav ul {
  display: flex;
  align-items: center;
  gap: 1.6rem;
  list-style: none;
  margin: 0;
  padding: 0;
}

.main-nav a {
  color: var(--ink-soft);
  text-decoration: none;
  font-size: 0.92rem;
  font-weight: 600;
  padding: 0.45rem 0.15rem;
  border-bottom: 2px solid transparent;
}

.main-nav a:hover {
  color: var(--accent);
}

.main-nav a.active {
  color: var(--accent);
  border-bottom-color: var(--gold);
}

/* Mobile nav collapse */

@media (max-width: 860px) {
  .nav-toggle {
    display: flex;
  }

  .main-nav {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--panel);
    border-bottom: 1px solid var(--line);
    box-shadow: 0 12px 24px var(--shadow);
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.2s ease;
  }

  .main-nav.open {
    max-height: 70vh;
    overflow-y: auto;
  }

  .main-nav ul {
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding: 0.5rem 1.5rem 1rem;
  }

  .main-nav ul > li {
    border-top: 1px solid var(--line);
  }

  .main-nav ul > li:first-child {
    border-top: none;
  }

  .main-nav a {
    display: block;
    width: 100%;
    padding: 0.85rem 0.2rem;
    text-align: left;
  }
}

/* ============ SITE FOOTER ============ */

.site-footer {
  border-top: 1px solid var(--line);
  background: var(--panel);
  padding: 1.4rem 2rem;
  margin-top: auto;
}

.footer-inner {
  max-width: 1280px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.8rem;
  font-size: 0.82rem;
  color: var(--ink-soft);
}

.footer-inner p {
  margin: 0;
}

.footer-links {
  display: flex;
  gap: 1.2rem;
  list-style: none;
  margin: 0;
  padding: 0;
}

.footer-links a {
  color: var(--ink-soft);
  text-decoration: none;
}

.footer-links a:hover {
  color: var(--accent);
}

/* ============ DASHBOARD MAIN AREA ============ */

.dashboard-main {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.page-head {
  padding: 2.25rem 2rem 1.5rem;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

.page-head h1 {
  font-family: var(--serif);
  font-size: 1.6rem;
  font-weight: 600;
  margin: 0 0 0.35rem;
  letter-spacing: 0.01em;
}

.page-head p {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.92rem;
  max-width: 62ch;
}

/* ============ PROMPT BUILDER TOOL LAYOUT ============ */

.layout {
  display: grid;
  grid-template-columns: minmax(320px, 460px) 1fr;
  gap: 0;
  flex: 1;
}

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
}

.form-pane {
  padding: 2rem;
  border-right: 1px solid var(--line);
  background: var(--panel);
}

.output-pane {
  padding: 2rem;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

fieldset {
  border: none;
  padding: 0;
  margin: 0 0 1.6rem;
}

legend {
  font-family: var(--serif);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--gold);
  margin-bottom: 0.7rem;
  padding: 0;
}

.field {
  margin-bottom: 0.9rem;
}

.field label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 0.3rem;
}

.field .hint {
  display: block;
  font-weight: 400;
  color: var(--ink-soft);
  font-size: 0.75rem;
  margin-top: 0.15rem;
}

input[type="text"],
input[type="email"],
input[type="tel"],
input[type="password"],
select,
textarea {
  width: 100%;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 0.9rem;
}

textarea {
  resize: vertical;
  min-height: 64px;
}

input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: var(--accent);
}

.row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.7rem;
}

.row-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 0.7rem;
}

.actions {
  position: sticky;
  bottom: 0;
  background: var(--panel);
  padding-top: 1rem;
  border-top: 1px solid var(--line);
  margin-top: 0.5rem;
}

button {
  font-family: var(--sans);
  font-weight: 600;
  font-size: 0.88rem;
  border-radius: 7px;
  border: 1px solid transparent;
  padding: 0.65rem 1.1rem;
  cursor: pointer;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  width: 100%;
}

.btn-primary:hover { background: #24392f; }

.output-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 0.8rem;
}

.output-head h2 {
  font-family: var(--serif);
  font-size: 1.1rem;
  margin: 0;
}

.btn-copy {
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid var(--accent);
  white-space: nowrap;
}

.btn-copy:hover { background: #d9e6dc; }

.btn-copy.copied {
  background: var(--accent);
  color: #fff;
}

#output {
  flex: 1;
  width: 100%;
  min-height: 420px;
  padding: 1.1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--code-bg);
  color: var(--code-text);
  font-family: var(--mono);
  font-size: 0.82rem;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-y: auto;
}

.empty-note {
  color: var(--ink-soft);
  font-size: 0.85rem;
  margin-top: 0.6rem;
}
