:root {
  --ink: #14202b;
  --muted: #5b6b7a;
  --line: #e5d9c6;
  --paper: #f4efe6;
  --card: #fffdf8;
  --teal: #0f6e5c;
  --teal-2: #14967c;
  --clay: #c45c26;
  --bad: #b42318;
  --good: #1f7a4d;
  --shadow: 0 18px 50px rgba(20, 32, 43, 0.08);
  --nav-h: 68px;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: Vazirmatn, Tahoma, system-ui, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(900px 420px at 100% -10%, #f3d3b8 0%, transparent 55%),
    radial-gradient(800px 380px at -10% 110%, #cfe7dc 0%, transparent 50%),
    var(--paper);
  line-height: 1.8;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font-family: inherit; }
img { max-width: 100%; }

.nav {
  position: sticky; top: 0; z-index: 45;
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; min-height: var(--nav-h);
  padding: 10px 16px;
  background: rgba(255, 253, 248, 0.92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand img { border-radius: 10px; }
.brand strong { display: block; font-size: 17px; }
.brand small { color: var(--muted); font-size: 11px; }
.nav-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; flex: none;
  border: 1px solid var(--line); background: #fff; border-radius: 12px;
  font-size: 22px; cursor: pointer; color: var(--ink);
}
.nav-scrim {
  display: none;
  position: fixed; inset: 0;
  background: rgba(20, 32, 43, 0.38);
  z-index: 40;
}
.nav-scrim.on { display: block; }
body.menu-open { overflow: hidden; }
.links {
  display: none;
  position: fixed;
  top: calc(var(--nav-h) + 8px);
  left: 12px;
  right: 12px;
  z-index: 50;
  background: #fffdf8;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 10px;
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
  box-shadow: 0 22px 60px rgba(20, 32, 43, 0.18);
  max-height: calc(100dvh - var(--nav-h) - 24px);
  overflow: auto;
}
.links.open { display: flex; }
.links a {
  padding: 12px 14px; border-radius: 12px; font-size: 16px; font-weight: 700; color: var(--ink);
}
.links a.is-active, .links a:hover { color: var(--ink); background: #efe6d6; }
.nav-cta {
  background: var(--ink) !important; color: #fff !important;
}
.links a.nav-out {
  color: #9b2c2c;
  background: #fde8e6;
  font-weight: 800;
  margin-top: 6px;
}

.hero, .wrap, .faq, .how, .tools-home { width: min(1120px, calc(100% - 32px)); margin: 0 auto; }
.hero { padding: 54px 0 30px; display: grid; grid-template-columns: 1.1fr 0.9fr; gap: 36px; align-items: center; }
.kicker {
  display: inline-block; background: #e7f4ef; color: var(--teal); font-weight: 800;
  font-size: 12px; padding: 5px 10px; border-radius: 999px;
}
.hero h1 { font-size: clamp(32px, 5vw, 56px); line-height: 1.25; margin: 12px 0; letter-spacing: -0.03em; }
.hero p.lead { font-size: 18px; color: var(--muted); margin: 0 0 22px; }
.cta-row { display: flex; gap: 10px; flex-wrap: wrap; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  border-radius: 14px; padding: 12px 18px; font-weight: 700; cursor: pointer;
  transition: transform .15s ease, box-shadow .15s ease, background .15s ease;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 10px 24px rgba(20,32,43,.08); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; box-shadow: none; }
.btn.primary { background: linear-gradient(180deg, #17856f, var(--teal)); border-color: var(--teal); color: #fff; }
.btn.primary:hover { background: linear-gradient(180deg, #1a927b, #0c5f50); }
.btn.dark { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn.ghost { background: transparent; }
.btn.wide { width: 100%; min-height: 48px; font-size: 15px; }

.preview {
  background: var(--card); border: 1px solid var(--line); border-radius: 24px;
  padding: 16px; box-shadow: var(--shadow);
}
.preview .bubble { max-width: 90%; padding: 10px 12px; border-radius: 16px; margin: 8px 0; font-size: 14px; }
.preview .me { background: var(--ink); color: #fff; }
.preview .ai { background: #efe6d6; margin-right: auto; }

.tools-home { padding: 20px 0 50px; display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 20px; padding: 18px;
  box-shadow: var(--shadow); display: block;
}
.card h3 { margin: 8px 0 6px; font-size: 18px; }
.card p { margin: 0; color: var(--muted); font-size: 14px; }
.icon {
  width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center;
  background: #e7f4ef; color: var(--teal); font-weight: 800;
}

.how, .faq { padding: 10px 0 50px; }
.how h2, .faq h2, .page-head h1 { margin: 0 0 14px; }
.steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.step { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 16px; }
.step b { color: var(--teal); }
details.q { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px 16px; margin: 8px 0; }
details.q summary { cursor: pointer; font-weight: 700; }

.foot { border-top: 1px solid var(--line); background: #fffdf8; padding: 28px 22px 18px; margin-top: 20px; }
.foot-grid { width: min(1120px, 100%); margin: 0 auto; display: grid; grid-template-columns: 1.4fr 1fr 1fr; gap: 18px; }
.foot a, .foot p { display: block; color: var(--muted); font-size: 14px; }
.foot span { display: block; font-weight: 800; margin-bottom: 6px; }
.copy { width: min(1120px, 100%); margin: 18px auto 0; color: var(--muted); font-size: 13px; }

.page-head { width: min(1120px, calc(100% - 32px)); margin: 28px auto 16px; }
.page-head p { color: var(--muted); margin: 6px 0 0; }

.app-shell {
  width: min(1200px, calc(100% - 20px));
  margin: 12px auto 16px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 22px;
  min-height: calc(100dvh - var(--nav-h) - 28px);
  display: grid;
  overflow: hidden;
  box-shadow: var(--shadow);
}
.app-shell.chat { grid-template-columns: 260px 1fr; }
.app-shell.write, .app-shell.code { grid-template-columns: 280px 1fr; }
.app-shell.image { grid-template-columns: 1fr; }

.side {
  border-left: 1px solid var(--line);
  background: #fbf7ef;
  padding: 14px;
  overflow: auto;
}
.side h2 { font-size: 14px; margin: 0 0 10px; }
.side-item, .tool-btn {
  width: 100%; text-align: right; border: 0; background: transparent;
  padding: 10px 10px; border-radius: 12px; cursor: pointer; font-weight: 650; color: var(--ink);
}
.side-item:hover, .tool-btn:hover, .tool-btn.active { background: #efe6d6; }
.field { margin-bottom: 12px; }
label { display: block; font-size: 12px; font-weight: 800; margin-bottom: 6px; }
select, textarea, input[type="text"], input[type="email"], input[type="password"] {
  width: 100%; border: 1px solid var(--line); background: #fff; border-radius: 14px;
  padding: 12px 14px; font-size: 16px; color: var(--ink); outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}
select:focus, textarea:focus, input[type="text"]:focus, input[type="email"]:focus, input[type="password"]:focus {
  border-color: #7db8ab; box-shadow: 0 0 0 4px rgba(15, 110, 92, 0.12);
}
input:disabled { background: #f3eee4; color: var(--muted); }
textarea { min-height: 120px; resize: vertical; line-height: 1.7; }

.chat-main { display: grid; grid-template-rows: 1fr auto; min-width: 0; }
#log, .outbox {
  overflow: auto; padding: 18px;
  display: flex; flex-direction: column; gap: 12px;
}
.msg {
  max-width: min(780px, 94%); padding: 12px 14px; border-radius: 16px;
  white-space: pre-wrap; word-break: break-word;
}
.msg.user { align-self: flex-start; background: var(--ink); color: #fff; }
.msg.bot { align-self: flex-end; background: #f4efe6; border: 1px solid var(--line); white-space: normal; }
.msg.sys { align-self: center; background: #efe6d6; font-size: 13px; color: #4a3b2a; }
.msg.err { background: #fde8e6; color: #7a1c16; border: 1px solid #f4c2bc; }
.msg .who { font-size: 11px; font-weight: 800; opacity: 0.7; margin-bottom: 4px; }
.msg pre {
  background: #14202b; color: #f4efe6; border-radius: 10px; padding: 10px;
  overflow: auto; direction: ltr; text-align: left; white-space: pre-wrap;
}
.msg code { font-family: ui-monospace, monospace; font-size: 13px; }
.composer { border-top: 1px solid var(--line); padding: 12px; background: #fffdf8; }
.box { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: end; }
#msg, .grow { min-height: 48px; max-height: 140px; margin: 0; }
.tiny { font-size: 12px; color: var(--muted); margin: 8px 4px 0; }

.studio { padding: 18px; display: grid; gap: 14px; }
.out {
  min-height: 220px; background: #fbf7ef; border: 1px dashed var(--line);
  border-radius: 16px; padding: 14px; white-space: pre-wrap;
}
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1px solid var(--line); background: #fff; border-radius: 999px;
  padding: 6px 12px; cursor: pointer; font-weight: 700; font-size: 13px;
}
.chip.on { background: var(--teal); color: #fff; border-color: var(--teal); }

.gallery {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px; padding: 0 18px 18px;
}
.gallery figure {
  margin: 0; background: #fff; border: 1px solid var(--line); border-radius: 16px; overflow: hidden;
}
.gallery img { display: block; width: 100%; height: 220px; object-fit: cover; background: #efe6d6; }
.gallery figcaption { padding: 8px 10px; font-size: 12px; color: var(--muted); }

.about, .error-page { width: min(800px, calc(100% - 32px)); margin: 30px auto 50px; }
.about .card { margin: 12px 0; }
.account-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.account-hero {
  display: flex; align-items: center; gap: 14px; margin-bottom: 18px;
  background: var(--card); border: 1px solid var(--line); border-radius: 22px;
  padding: 18px; box-shadow: var(--shadow);
}
.avatar {
  width: 56px; height: 56px; border-radius: 16px; flex: none;
  display: grid; place-items: center; font-size: 22px; font-weight: 800; color: #fff;
  background: linear-gradient(145deg, #17856f, #0b4f43);
}
.account-hero h1 { margin: 0; font-size: 22px; }
.account-hero p { margin: 4px 0 0; color: var(--muted); }

.banner {
  width: min(1120px, calc(100% - 24px)); margin: 12px auto 0;
  padding: 11px 16px; border-radius: 14px; font-size: 14px;
}
.auth-card .banner { width: auto; margin: 0 0 14px; }
.banner.ok { background: #e7f4ef; color: #145c3d; border: 1px solid #b7e0cc; }
.banner.bad, .banner.err { background: #fde8e6; color: #7a1c16; border: 1px solid #f4c2bc; }
.banner.info { background: #fff4d6; color: #5c4308; border: 1px solid #efd48a; }

.field-box { margin-bottom: 14px; }
.field-box label { margin-bottom: 8px; font-size: 13px; }
.input-wrap {
  position: relative; display: flex; align-items: center;
  background: #fff; border: 1px solid var(--line); border-radius: 14px;
}
.input-wrap:focus-within { border-color: #7db8ab; box-shadow: 0 0 0 4px rgba(15,110,92,.12); }
.input-wrap .input-ico {
  width: 36px; flex: none; text-align: center; color: var(--teal); font-weight: 800; font-size: 13px;
}
.input-wrap input {
  border: 0 !important; box-shadow: none !important; background: transparent;
  padding: 12px 10px 12px 6px;
}
.input-wrap .eye, .float .eye {
  border: 0; background: transparent; color: var(--muted); font-weight: 800;
  font-size: 12px; padding: 0 12px; cursor: pointer;
}

body.is-auth {
  background:
    radial-gradient(900px 480px at 50% -10%, #d7efe6 0%, transparent 58%),
    radial-gradient(700px 420px at 110% 110%, #f3d3b8 0%, transparent 50%),
    #efe6d4;
}
body.is-auth main {
  min-height: calc(100dvh - var(--nav-h));
  display: grid;
  place-items: center;
  padding: 28px 16px 40px;
}
.auth-screen { width: min(420px, 100%); }
.auth-pass {
  background: #fffdf9;
  border-radius: 22px;
  box-shadow:
    0 1px 0 rgba(255,255,255,.7) inset,
    0 28px 70px rgba(20, 48, 40, .16);
  overflow: hidden;
  border: 1px solid rgba(20, 32, 43, .06);
}
.auth-ribbon {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  background:
    radial-gradient(120px 80px at 100% 0%, rgba(232,192,122,.28), transparent 70%),
    linear-gradient(135deg, #0f6e5c, #16352e);
  color: #f7f1e6;
}
.auth-ribbon img { width: 36px; height: 36px; border-radius: 10px; }
.auth-ribbon strong { display: block; font-size: 16px; letter-spacing: -.02em; }
.auth-ribbon span { display: block; font-size: 12px; opacity: .78; }
.auth-cut {
  height: 16px;
  background:
    radial-gradient(circle at 0 50%, transparent 9px, #fffdf9 9.5px) left,
    radial-gradient(circle at 100% 50%, transparent 9px, #fffdf9 9.5px) right,
    repeating-linear-gradient(90deg, transparent 0 8px, #e5d9c6 8px 10px);
  background-size: 16px 16px, 16px 16px, 100% 2px;
  background-position: left center, right center, center;
  background-repeat: no-repeat, no-repeat, repeat-x;
  background-color: #fffdf9;
}
.auth-body { padding: 8px 22px 8px; display: grid; gap: 12px; }
.auth-body .banner { width: auto; margin: 6px 0 2px; }
.float {
  position: relative;
  display: block;
  margin: 0;
}
.float input {
  width: 100%;
  height: 56px;
  padding: 22px 14px 8px;
  border: 1px solid #e4d9c8;
  border-radius: 14px;
  background: #fbf7ef;
  font-size: 16px;
}
.float input:focus {
  background: #fff;
  border-color: #7db8ab;
  box-shadow: 0 0 0 4px rgba(15,110,92,.12);
}
.float span {
  position: absolute;
  right: 14px;
  top: 18px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
  pointer-events: none;
  transition: .16s ease;
}
.float input:focus + span,
.float input:not(:placeholder-shown) + span {
  top: 8px;
  font-size: 11px;
  color: var(--teal);
}
.float .eye { position: absolute; left: 6px; top: 50%; transform: translateY(-50%); }
.auth-alt {
  display: block;
  text-align: center;
  padding: 14px 18px 18px;
  color: var(--muted);
  font-size: 14px;
  background: linear-gradient(#f7f1e6, #f3eee3);
}
.auth-alt b { color: var(--teal); }
.check { display: flex; align-items: center; gap: 8px; font-weight: 700; }
.settings-form { max-width: 640px; }

.admin-wrap {
  width: min(1200px, calc(100% - 16px));
  margin: 12px auto 24px;
  display: grid;
  grid-template-columns: 230px 1fr;
  gap: 14px;
  min-height: calc(100dvh - var(--nav-h) - 40px);
}
.admin-side {
  background: #14202b; color: #f4efe6; border-radius: 20px; padding: 16px;
  display: flex; flex-direction: column; gap: 6px;
}
.admin-side h2 { margin: 0 0 8px; font-size: 15px; }
.admin-side a { color: #d9cbb6; padding: 10px 12px; border-radius: 12px; font-weight: 700; }
.admin-side a.is-active, .admin-side a:hover { background: #1f3344; color: #fff; }
.admin-main { background: var(--card); border: 1px solid var(--line); border-radius: 20px; padding: 18px; min-width: 0; }
.admin-toggle { display: none; }
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 12px 0 18px; }
.stat-grid .card h3 { margin: 0; font-size: 28px; }
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td { border-bottom: 1px solid var(--line); padding: 10px 8px; text-align: right; vertical-align: top; }
.row-actions, .inline-form { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.row-actions .btn, .inline-form .btn { padding: 7px 10px; font-size: 12px; }
.bad-btn { background: #fde8e6; color: #7a1c16; border-color: #f4c2bc; }
.error-page {
  text-align: center; background: var(--card); border: 1px solid var(--line);
  border-radius: 28px; padding: 40px 24px; box-shadow: var(--shadow);
}

@media (max-width: 1100px) {
  .tools-home { grid-template-columns: repeat(2, 1fr); }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 900px) {
  .hero, .steps, .foot-grid, .app-shell.chat, .app-shell.write, .app-shell.code,
  .admin-wrap, .account-grid { grid-template-columns: 1fr; }
  .hero { padding-top: 22px; }
  .side { border-left: 0; border-bottom: 1px solid var(--line); max-height: 240px; }
  .admin-toggle { display: inline-flex; }
  .admin-side { display: none; }
  .admin-side.open { display: flex; }
}

@media (max-width: 640px) {
  .tools-home, .stat-grid { grid-template-columns: 1fr; }
  .brand small { display: none; }
  .box { grid-template-columns: 1fr; }
  #send { width: 100%; }
  .preview { display: none; }
}
