:root {
  --bg: #f7f7f5;
  --surface: #fff;
  --surface-2: #f0f0ee;
  --border: #e5e5e3;
  --border-light: #eee;
  --text: #1a1a1a;
  --text-muted: #888;
  --text-light: #aaa;
  --primary: #991b1e;
  --primary-hover: #7a1517;
  --primary-bg: #fef2f2;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 2px 8px rgba(0,0,0,0.06);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; font-family: Inter, -apple-system, BlinkMacSystemFont, sans-serif; font-size: 16px; color: var(--text); background: var(--bg); }

.is-hidden { display: none !important; }

.login-form {
  margin-top: 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  max-width: 340px;
  width: 100%;
}
.login-field {
  width: 100%;
  text-align: left;
}
.login-field label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}
.login-field input {
  width: 100%;
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-family: inherit;
  background: var(--surface);
  color: var(--text);
}
.login-field input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-bg);
}
.login-error {
  width: 100%;
  background: var(--primary-bg);
  color: var(--primary);
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  text-align: center;
}

.auth-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  max-width: 340px;
  width: 100%;
}
.auth-tab {
  flex: 1;
  padding: 0.6rem 1rem;
  border: none;
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
.auth-tab.active {
  background: var(--primary);
  color: #fff;
}
.auth-tab:hover:not(.active) {
  background: var(--border);
}

.field-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}
.slug-ok { color: #16a34a; font-weight: 600; }
.slug-taken { color: var(--primary); font-weight: 600; }
.btn-danger { background: #dc2626; color: #fff; border: 1px solid #dc2626; }
.btn-danger:hover { background: #b91c1c; }
.topbar-user { font-size: 0.85rem; color: var(--text-muted); margin-right: 0.75rem; }

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 1.5rem; height: 56px; background: var(--surface);
  border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 100;
}
.topbar-brand { display: flex; align-items: center; gap: 0.75rem; }
.logo { font-size: 0.8rem; font-weight: 700; letter-spacing: 0.25em; text-transform: uppercase; color: var(--primary); }
.tagline { font-size: 0.65rem; color: var(--text-light); letter-spacing: 0.15em; text-transform: uppercase; }
.topbar-right { display: flex; align-items: center; gap: 1rem; }
.topbar-user { font-size: 0.82rem; color: var(--text-muted); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
  padding: 8px 18px; font-size: 0.72rem; font-weight: 600;
  cursor: pointer; border: none; text-align: center; letter-spacing: 0.08em;
  text-transform: uppercase; transition: background 0.15s, border-color 0.15s, color 0.15s;
  text-decoration: none; border-radius: var(--radius-sm); white-space: nowrap;
  font-family: inherit;
}
.btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--text); }
.btn-ghost { background: transparent; border: none; color: var(--text-muted); padding: 6px 12px; }
.btn-ghost:hover { color: var(--text); background: var(--surface-2); }
.btn-sm { padding: 5px 12px; font-size: 0.68rem; }
.btn-lg { padding: 12px 36px; font-size: 0.78rem; }
.btn-icon { padding: 8px; width: 38px; height: 38px; border-radius: 50%; }
.btn-block { width: 100%; margin-top: 0.5rem; }

.hero-landing {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: calc(100vh - 56px); text-align: center; padding: 4rem 2rem;
}
.landing-icon { color: var(--primary); margin-bottom: 1.5rem; opacity: 0.7; }
.hero-landing h1 { font-size: 2.2rem; font-weight: 600; margin-bottom: 0.75rem; letter-spacing: -0.02em; }
.hero-landing p { font-size: 0.95rem; color: var(--text-muted); max-width: 440px; margin-bottom: 0.5rem; line-height: 1.7; }

.dashboard { display: flex; height: calc(100vh - 56px); overflow: hidden; }

.sidebar {
  width: 240px; background: var(--surface); border-right: 1px solid var(--border);
  padding: 1.25rem; flex-shrink: 0; display: flex; flex-direction: column; gap: 1.5rem;
  overflow-y: auto;
}
.sidebar-section h3 {
  font-size: 0.65rem; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase;
  margin-bottom: 0.6rem; color: var(--text-light);
}

.site-item {
  padding: 0.6rem 0.75rem; margin-bottom: 0.35rem; border: 1px solid var(--border);
  border-radius: var(--radius-sm); cursor: pointer; transition: border-color 0.15s, background 0.15s;
}
.site-item:hover { border-color: var(--primary); }
.site-item.active { border-color: var(--primary); background: var(--primary-bg); }
.site-item-name { font-size: 0.85rem; font-weight: 500; }
.site-item-status { font-size: 0.68rem; color: var(--text-light); margin-top: 0.15rem; }

.page-item {
  padding: 0.4rem 0.6rem; margin-bottom: 0.25rem; font-size: 0.82rem; cursor: pointer;
  border-radius: var(--radius-sm); transition: background 0.15s, color 0.15s;
}
.page-item:hover { background: var(--surface-2); }
.page-item.active { background: var(--primary-bg); color: var(--primary); font-weight: 500; }

.chat-main { flex: 1; display: flex; flex-direction: column; min-width: 0; overflow: hidden; }

.chat-empty {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 3rem; color: var(--text-muted);
}
.chat-empty-icon { margin-bottom: 1rem; opacity: 0.4; }
.chat-empty h2 { font-size: 1.2rem; font-weight: 500; color: var(--text); margin-bottom: 0.5rem; }
.chat-empty p { font-size: 0.88rem; max-width: 360px; line-height: 1.6; }

.chat-area { flex: 1; display: flex; flex-direction: column; min-height: 0; overflow: hidden; }

.chat-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.75rem 1.25rem; border-bottom: 1px solid var(--border); background: var(--surface);
  flex-shrink: 0;
}
.chat-header-info { display: flex; align-items: center; gap: 0.5rem; min-width: 0; }
.chat-site-name { font-size: 0.9rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-divider { color: var(--text-light); flex-shrink: 0; }
#chat-page-select {
  font-size: 0.85rem; border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 4px 8px; outline: none; background: var(--surface); cursor: pointer; font-family: inherit;
  max-width: 200px;
}
#chat-page-select:focus { border-color: var(--primary); }
.chat-header-actions { display: flex; gap: 0.4rem; flex-shrink: 0; }

.chat-messages {
  flex: 1; overflow-y: auto; padding: 1.5rem; display: flex; flex-direction: column; gap: 1rem;
  scroll-behavior: smooth;
}

.chat-welcome {
  text-align: center; padding: 2rem; color: var(--text-muted); font-size: 0.9rem; line-height: 1.6;
  max-width: 480px; margin: 0 auto;
}

.msg { display: flex; gap: 0.75rem; max-width: 720px; animation: msgIn 0.2s ease; }
@keyframes msgIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.msg-user { align-self: flex-end; flex-direction: row-reverse; }
.msg-ai { align-self: flex-start; }

.msg-avatar {
  width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.65rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em;
}
.msg-user .msg-avatar { background: var(--primary); color: #fff; }
.msg-ai .msg-avatar { background: var(--surface-2); color: var(--text-muted); border: 1px solid var(--border); }

.msg-bubble {
  padding: 0.75rem 1rem; border-radius: var(--radius); line-height: 1.6; font-size: 0.88rem;
  overflow-wrap: break-word; word-break: break-word;
}
.msg-bubble p { margin: 0; }
.msg-user .msg-bubble { background: var(--primary); color: #fff; border-bottom-right-radius: 3px; }
.msg-ai .msg-bubble { background: var(--surface); border: 1px solid var(--border); border-bottom-left-radius: 3px; }

.msg-media {
  display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.5rem;
}
.msg-media img {
  width: 120px; height: 90px; object-fit: cover; border-radius: var(--radius-sm);
  border: 1px solid var(--border); cursor: pointer; transition: transform 0.15s;
}
.msg-media img:hover { transform: scale(1.05); }

.msg-sections { margin-top: 0.75rem; display: flex; flex-direction: column; gap: 0.5rem; }
.msg-section-card {
  background: var(--surface-2); border: 1px solid var(--border-light); border-radius: var(--radius-sm);
  padding: 0.6rem 0.8rem;
}
.msg-section-card .sec-kind {
  font-size: 0.62rem; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--primary); margin-bottom: 0.2rem;
}
.msg-section-card .sec-heading { font-size: 0.82rem; font-weight: 500; margin-bottom: 0.15rem; }
.msg-section-card .sec-body { font-size: 0.78rem; color: var(--text-muted); line-height: 1.5; }

.sec-preview-label {
  font-size: 0.72rem; font-weight: 600; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--text-light); margin-bottom: 0.4rem;
}

.msg-typing { display: flex; gap: 4px; align-items: center; padding: 4px 0; }
.msg-typing span {
  width: 6px; height: 6px; border-radius: 50%; background: var(--text-light);
  animation: typing 1.2s infinite;
}
.msg-typing span:nth-child(2) { animation-delay: 0.2s; }
.msg-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typing { 0%, 60%, 100% { opacity: 0.3; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-4px); } }

.chat-attachments {
  padding: 0.5rem 1.25rem; border-top: 1px solid var(--border-light);
  display: flex; flex-wrap: wrap; gap: 0.5rem; background: var(--surface);
  flex-shrink: 0;
}
.attachment-thumb {
  position: relative; width: 64px; height: 64px; border-radius: var(--radius-sm);
  overflow: hidden; border: 1px solid var(--border);
}
.attachment-thumb img { width: 100%; height: 100%; object-fit: cover; }
.attachment-remove {
  position: absolute; top: 2px; right: 2px; width: 18px; height: 18px; border-radius: 50%;
  background: rgba(0,0,0,0.6); color: #fff; border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center; font-size: 11px; line-height: 1;
  padding: 0;
}
.attachment-remove:focus-visible { outline: 2px solid #fff; }

.chat-input-area {
  display: flex; align-items: flex-end; gap: 0.5rem; padding: 0.75rem 1.25rem;
  border-top: 1px solid var(--border); background: var(--surface);
  flex-shrink: 0;
}
.chat-input-wrap { flex: 1; }
.chat-input-wrap textarea {
  width: 100%; padding: 0.6rem 0.8rem; border: 1px solid var(--border); border-radius: var(--radius);
  font-size: 0.88rem; font-family: inherit; resize: none; outline: none; line-height: 1.5;
  min-height: 40px; max-height: 160px; background: var(--bg);
}
.chat-input-wrap textarea:focus { border-color: var(--primary); }

.modal {
  position: fixed; inset: 0; background: rgba(0,0,0,0.4); display: flex;
  align-items: center; justify-content: center; z-index: 200;
}
.modal-content {
  background: var(--surface); padding: 2rem; border-radius: var(--radius);
  width: 100%; max-width: 440px; box-shadow: var(--shadow);
}
.modal-content h2 { font-size: 1.1rem; margin-bottom: 1.5rem; font-weight: 600; }
.modal-content label { display: block; font-size: 0.7rem; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; margin-bottom: 0.4rem; color: var(--text-muted); }
.modal-content input, .modal-content select {
  width: 100%; padding: 0.65rem 0.75rem; border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: 0.88rem; margin-bottom: 1rem; outline: none; font-family: inherit;
}
.modal-content input:focus, .modal-content select:focus { border-color: var(--primary); }
.modal-actions { display: flex; justify-content: flex-end; gap: 0.5rem; margin-top: 0.5rem; }

.modal-content--wide { max-width: 820px; }

.plan-badge {
  display: inline-block; font-size: 0.68rem; font-weight: 700; letter-spacing: 0.08em;
  text-transform: uppercase; padding: 3px 10px; border-radius: 20px; margin-bottom: 0.6rem;
}
.plan-badge--free { background: #f0f0ee; color: #888; }
.plan-badge--starter { background: #eef7ee; color: #2d7a2d; }
.plan-badge--pro { background: #eef0f7; color: #3a3a8a; }
.plan-badge--agency { background: #fef2f2; color: var(--primary); }

.plan-meter { margin-bottom: 0.45rem; }
.plan-meter-label { font-size: 0.68rem; color: var(--text-muted); display: block; }
.plan-meter-val { font-size: 0.65rem; color: var(--text-light); float: right; }
.plan-meter-track {
  height: 4px; background: var(--surface-2); border-radius: 2px; margin-top: 2px; overflow: hidden;
}
.plan-meter-bar { height: 100%; background: var(--primary); border-radius: 2px; transition: width 0.3s; }
.plan-meter-bar--warn { background: #d4930a; }
.plan-meter-bar--danger { background: #c0392b; }

.pricing-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 1rem; margin: 1rem 0; }

.pricing-card {
  border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem;
  text-align: center; transition: border-color 0.2s, box-shadow 0.2s;
}
.pricing-card:hover { border-color: var(--primary); box-shadow: 0 2px 12px rgba(0,0,0,0.08); }
.pricing-card--current { border-color: var(--primary); background: var(--primary-bg); }

.pricing-name { font-size: 0.72rem; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; margin-bottom: 0.5rem; }
.pricing-price { font-size: 1.3rem; font-weight: 600; margin-bottom: 0.75rem; }
.pricing-features {
  list-style: none; font-size: 0.78rem; color: var(--text-muted); text-align: left;
  margin-bottom: 1rem; line-height: 1.8;
}
.pricing-features li::before { content: "\2713 "; color: var(--primary); font-weight: 700; }

.domain-display { margin-bottom: 0.5rem; }
.domain-tag { display: inline-block; padding: 4px 10px; background: var(--bg-cream); border: 1px solid var(--border); border-radius: 6px; font-size: 0.8rem; color: var(--text-muted); word-break: break-all; }

.billing-banner{padding:10px 14px;border-radius:8px;background:var(--bg-cream,#f5efe7);margin-bottom:12px;font-size:0.95rem}
.billing-banner--warn{background:#fde8e8;color:#8a1c1c}
.billing-period-toggle{display:flex;gap:4px;margin-bottom:12px}
.period-btn{padding:6px 14px;border:1px solid var(--border,#ccc);background:#fff;cursor:pointer;border-radius:6px}
.period-btn--active{background:var(--navy,#6B1D2A);color:#fff}

@media (max-width: 1024px) {
  .sidebar { width: 200px; }
}
@media (max-width: 768px) {
  .dashboard { flex-direction: column; height: auto; }
  .sidebar { width: 100%; border-right: none; border-bottom: 1px solid var(--border); flex-direction: row; overflow-x: auto; padding: 0.75rem; gap: 1rem; max-height: 120px; }
  .sidebar-section { flex-shrink: 0; }
  .chat-main { height: calc(100vh - 56px - 120px); }
}
