:root {
  --ink: #181815;
  --muted: #716f68;
  --soft: #9b9991;
  --line: #e5e3dc;
  --line-strong: #d5d2c8;
  --paper: #fbfaf7;
  --canvas: #f4f3ee;
  --white: #ffffff;
  --accent: #1e5848;
  --accent-hover: #16473a;
  --accent-soft: #e4eee9;
  --amber: #c07b2b;
  --blue: #4c72a7;
  --green: #4e7c64;
  --danger: #a9463d;
  --shadow-sm: 0 1px 2px rgba(25, 25, 20, 0.05), 0 4px 14px rgba(25, 25, 20, 0.04);
  --shadow-lg: 0 24px 80px rgba(19, 25, 22, 0.14);
  --radius: 14px;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--canvas);
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { font-size: 14px; -webkit-font-smoothing: antialiased; }
button, input, textarea { font: inherit; }
button { color: inherit; }
[hidden] { display: none !important; }

.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  text-decoration: none;
  font-size: 16px;
  font-weight: 680;
  letter-spacing: -0.02em;
}

.wordmark-light { color: #f7f8f4; }

.brand-mark, .welcome-mark {
  position: relative;
  display: inline-flex;
  width: 27px;
  height: 27px;
  align-items: center;
  justify-content: center;
  border-radius: 9px;
  background: var(--ink);
  overflow: hidden;
}

.brand-mark i, .welcome-mark i {
  position: absolute;
  width: 4px;
  height: 14px;
  border-radius: 4px;
  background: #f5f5ef;
  transform: rotate(32deg) translateX(-3px);
}

.brand-mark i + i, .welcome-mark i + i {
  transform: rotate(32deg) translateX(4px);
  opacity: .58;
}

.wordmark-light .brand-mark { background: #f5f5ef; }
.wordmark-light .brand-mark i { background: #173d34; }

.eyebrow {
  margin: 0 0 12px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 750;
  letter-spacing: .13em;
  text-transform: uppercase;
}

.eyebrow-light { color: #9dcbbb; }

/* Login */
.login-page { background: #e9ebe5; }

.login-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(360px, 46%) 1fr;
}

.login-brand {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 42px 48px;
  color: #f6f8f4;
  background:
    radial-gradient(circle at 12% 12%, rgba(114, 177, 150, .19), transparent 34%),
    radial-gradient(circle at 86% 84%, rgba(128, 151, 137, .16), transparent 28%),
    linear-gradient(145deg, #13382f 0%, #142a25 56%, #101d1a 100%);
  overflow: hidden;
  position: relative;
}

.login-brand::after {
  content: "";
  position: absolute;
  width: 520px;
  height: 520px;
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 50%;
  right: -280px;
  top: 16%;
  box-shadow: 0 0 0 70px rgba(255,255,255,.025), 0 0 0 140px rgba(255,255,255,.018);
}

.login-message { max-width: 560px; position: relative; z-index: 1; }
.login-message h1 {
  max-width: 520px;
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(44px, 5.5vw, 76px);
  line-height: .99;
  font-weight: 400;
  letter-spacing: -.045em;
}

.login-message > p:last-child {
  max-width: 480px;
  margin: 28px 0 0;
  color: rgba(245,248,243,.72);
  font-size: 17px;
  line-height: 1.65;
}

.login-footnote { margin: 0; color: rgba(245,248,243,.5); font-size: 12px; }

.login-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px;
  background: #f7f7f3;
}

.login-card { width: min(100%, 420px); }
.login-card h2 { margin: 0; font-size: 31px; letter-spacing: -.035em; }
.login-helper { margin: 12px 0 30px; color: var(--muted); font-size: 15px; line-height: 1.55; }
.login-card form { display: grid; gap: 9px; }
.login-card label { margin-top: 8px; font-size: 12px; font-weight: 700; }
.login-card input {
  width: 100%;
  height: 50px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  padding: 0 14px;
  background: var(--white);
  outline: none;
  transition: border-color .18s, box-shadow .18s;
}
.login-card input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(30,88,72,.1); }
.primary-button {
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border: 0;
  border-radius: 10px;
  padding: 0 17px;
  color: var(--white);
  background: var(--accent);
  font-weight: 700;
  cursor: pointer;
  transition: background .18s, transform .18s;
}
.primary-button:hover { background: var(--accent-hover); }
.primary-button:active { transform: translateY(1px); }
.primary-button:disabled { opacity: .62; cursor: wait; }
.full-button { width: 100%; margin-top: 15px; }
.form-error { margin: 5px 0 0; color: var(--danger); font-size: 13px; }
.future-auth { display: flex; align-items: center; gap: 12px; margin: 30px 0 12px; color: var(--soft); font-size: 11px; text-transform: uppercase; letter-spacing: .08em; }
.future-rule { height: 1px; flex: 1; background: var(--line); }
.future-copy { margin: 0; color: var(--soft); font-size: 12px; line-height: 1.55; text-align: center; }

/* Workspace shell */
.workspace-page { background: var(--paper); overflow: hidden; }
.app-shell { min-height: 100vh; display: grid; grid-template-columns: 260px minmax(0, 1fr); }

.sidebar {
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 18px 13px 13px;
  border-right: 1px solid var(--line);
  background: #f0efe9;
  z-index: 20;
}

.sidebar-top { height: 38px; display: flex; align-items: center; justify-content: space-between; padding: 0 8px; }
.new-work-button {
  width: 100%;
  height: 43px;
  display: grid;
  grid-template-columns: 24px 1fr auto;
  align-items: center;
  gap: 8px;
  margin: 17px 0 13px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  padding: 0 10px;
  background: rgba(255,255,255,.72);
  box-shadow: var(--shadow-sm);
  font-size: 13px;
  font-weight: 650;
  text-align: left;
  cursor: pointer;
}
.new-work-button:hover { background: var(--white); }
.plus-mark { width: 22px; height: 22px; display: grid; place-items: center; border-radius: 7px; background: var(--accent); color: var(--white); font-size: 17px; line-height: 1; }
.shortcut { color: var(--soft); font-size: 11px; font-weight: 500; }

.primary-nav { display: grid; gap: 2px; }
.nav-item {
  width: 100%;
  height: 36px;
  display: grid;
  grid-template-columns: 24px 1fr auto;
  align-items: center;
  gap: 7px;
  border: 0;
  border-radius: 8px;
  padding: 0 9px;
  color: var(--muted);
  background: transparent;
  text-align: left;
  cursor: pointer;
}
.nav-item.active { color: var(--ink); background: rgba(255,255,255,.62); font-weight: 650; }
.nav-item:disabled { cursor: default; opacity: .68; }
.nav-item small { color: var(--soft); font-size: 9px; text-transform: uppercase; letter-spacing: .08em; }

.recent-section { flex: 1; min-height: 0; margin-top: 23px; display: flex; flex-direction: column; }
.section-heading { display: flex; justify-content: space-between; padding: 0 9px 9px; color: var(--soft); font-size: 10px; font-weight: 750; letter-spacing: .09em; text-transform: uppercase; }
.history-list { min-height: 0; overflow-y: auto; display: grid; align-content: start; gap: 3px; scrollbar-width: thin; }
.history-item {
  width: 100%;
  display: grid;
  gap: 6px;
  border: 0;
  border-radius: 8px;
  padding: 9px;
  background: transparent;
  text-align: left;
  cursor: pointer;
}
.history-item:hover, .history-item.active { background: rgba(255,255,255,.68); }
.history-item strong { overflow: hidden; color: #3c3b36; font-size: 12px; font-weight: 590; text-overflow: ellipsis; white-space: nowrap; }
.history-item span { display: flex; align-items: center; gap: 5px; color: var(--soft); font-size: 10px; }
.status-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--amber); }
.status-dot.done { background: var(--green); }
.status-dot.needs_attention { background: var(--danger); }
.status-dot.cancelled { background: var(--soft); }
.history-empty { margin: 5px 9px; color: var(--soft); font-size: 11px; line-height: 1.5; }
.history-skeleton { display: grid; gap: 8px; padding: 7px 9px; }
.history-skeleton i { height: 31px; border-radius: 7px; background: linear-gradient(90deg, #e7e5de, #efeee9, #e7e5de); background-size: 200% 100%; animation: shimmer 1.4s infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }

.sidebar-bottom { position: relative; display: grid; gap: 7px; padding-top: 10px; border-top: 1px solid var(--line); }
.preview-badge { display: flex; align-items: center; gap: 7px; padding: 1px 9px 5px; color: var(--soft); font-size: 10px; }
.preview-badge span { width: 6px; height: 6px; border-radius: 50%; background: #d59c3e; box-shadow: 0 0 0 3px rgba(213,156,62,.13); }
.account-button {
  width: 100%;
  display: grid;
  grid-template-columns: 34px 1fr auto;
  align-items: center;
  gap: 9px;
  border: 0;
  border-radius: 9px;
  padding: 7px;
  background: transparent;
  text-align: left;
  cursor: pointer;
}
.account-button:hover { background: rgba(255,255,255,.68); }
.avatar, .message-avatar { display: grid; place-items: center; border-radius: 9px; color: #fff; background: var(--accent); font-size: 10px; font-weight: 750; }
.avatar { width: 34px; height: 34px; }
.account-copy { min-width: 0; display: grid; gap: 2px; }
.account-copy strong, .account-copy small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-copy strong { font-size: 11px; }
.account-copy small { color: var(--soft); font-size: 9px; }
.logout-button { position: absolute; left: 4px; right: 4px; bottom: 52px; height: 38px; border: 1px solid var(--line); border-radius: 9px; background: var(--white); box-shadow: var(--shadow-sm); color: var(--danger); cursor: pointer; }

.workspace-main { height: 100vh; min-width: 0; display: grid; grid-template-rows: 58px minmax(0,1fr) auto; background: var(--paper); }
.topbar { display: grid; grid-template-columns: 1fr auto; align-items: center; padding: 0 24px; border-bottom: 1px solid var(--line); background: rgba(251,250,247,.9); backdrop-filter: blur(16px); z-index: 10; }
.topbar-title { min-width: 0; display: flex; align-items: center; gap: 12px; font-size: 13px; font-weight: 680; }
.topbar-title > span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.connection-state { flex: 0 0 auto; display: inline-flex; align-items: center; color: var(--soft); font-size: 10px; font-weight: 550; }
.connection-state i { width: 6px; height: 6px; border-radius: 50%; background: #63a177; }
.connection-state.working i { background: var(--amber); animation: pulse 1.2s infinite; }
.connection-state.attention i { background: var(--danger); }
@keyframes pulse { 50% { opacity: .3; } }
.topbar-actions { display: flex; gap: 8px; }
.quiet-button, .share-button, .icon-button { height: 32px; border: 1px solid var(--line); border-radius: 8px; padding: 0 11px; background: transparent; color: var(--muted); font-size: 11px; }
.share-button { background: var(--ink); color: var(--white); border-color: var(--ink); }
.quiet-button:disabled, .share-button:disabled { opacity: .5; }
.icon-button { width: 32px; padding: 0; font-size: 18px; }

.conversation { overflow-y: auto; padding: 0 32px 40px; scrollbar-width: thin; }
.welcome-state { min-height: 100%; max-width: 790px; margin: 0 auto; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 56px 0 62px; text-align: center; }
.welcome-mark { width: 42px; height: 42px; margin-bottom: 18px; border-radius: 13px; background: var(--accent); box-shadow: 0 10px 28px rgba(30,88,72,.2); }
.welcome-mark i { width: 5px; height: 21px; }
.welcome-state h1 { margin: 0; font-family: Georgia, "Times New Roman", serif; font-size: clamp(34px, 4.2vw, 52px); line-height: 1.08; font-weight: 400; letter-spacing: -.04em; }
.welcome-copy { max-width: 570px; margin: 16px 0 31px; color: var(--muted); font-size: 15px; line-height: 1.6; }
.suggestion-grid { width: 100%; display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.suggestion-card { min-height: 112px; display: grid; grid-template-columns: 34px 1fr; align-items: start; gap: 12px; border: 1px solid var(--line); border-radius: 13px; padding: 16px; background: rgba(255,255,255,.6); text-align: left; cursor: pointer; transition: border-color .18s, background .18s, transform .18s, box-shadow .18s; }
.suggestion-card:hover { border-color: var(--line-strong); background: var(--white); transform: translateY(-2px); box-shadow: var(--shadow-sm); }
.suggestion-icon { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 9px; font-size: 16px; }
.suggestion-icon.amber { color: #955d1c; background: #f7ead9; }
.suggestion-icon.blue { color: #3e608b; background: #e5edf7; }
.suggestion-icon.green { color: #3d6952; background: #e2eee7; }
.suggestion-card span:last-child { display: grid; gap: 6px; }
.suggestion-card strong { font-size: 12px; }
.suggestion-card small { color: var(--muted); font-size: 11px; line-height: 1.4; }

.messages { width: min(100%, 820px); margin: 0 auto; padding: 42px 0 20px; }
.message { display: grid; grid-template-columns: 34px minmax(0,1fr); gap: 14px; padding: 20px 0 25px; border-bottom: 1px solid var(--line); }
.message:last-child { border-bottom: 0; }
.message-avatar { width: 32px; height: 32px; }
.message.assistant .message-avatar { color: var(--accent); background: var(--accent-soft); }
.message-content { min-width: 0; padding-top: 3px; }
.message-content > strong { display: block; margin-bottom: 8px; font-size: 12px; }
.message-body { color: #373631; font-size: 14px; line-height: 1.7; white-space: pre-wrap; overflow-wrap: anywhere; }
.run-progress { display: inline-flex; align-items: center; gap: 7px; margin-top: 13px; border: 1px solid var(--line); border-radius: 999px; padding: 6px 10px; color: var(--muted); background: var(--white); font-size: 10px; font-weight: 650; }
.run-progress i { width: 7px; height: 7px; border-radius: 50%; background: var(--amber); animation: pulse 1.2s infinite; }
.run-progress.done i { background: var(--green); animation: none; }
.run-progress.needs_attention i { background: var(--danger); animation: none; }
.run-progress.cancelled i { background: var(--soft); animation: none; }

.composer-zone { width: 100%; padding: 0 24px 16px; background: linear-gradient(180deg, rgba(251,250,247,0), var(--paper) 28%); }
.composer, .global-alert, .composer-note { width: min(100%, 820px); margin-left: auto; margin-right: auto; }
.global-alert { margin-bottom: 8px; border: 1px solid #e3bbb5; border-radius: 9px; padding: 9px 12px; color: #7d3730; background: #fff1ef; font-size: 11px; }
.composer { border: 1px solid var(--line-strong); border-radius: 16px; padding: 11px 11px 9px 14px; background: var(--white); box-shadow: 0 9px 35px rgba(30,30,23,.08); transition: border-color .18s, box-shadow .18s; }
.composer:focus-within { border-color: #aaa79e; box-shadow: 0 10px 42px rgba(30,30,23,.11); }
.composer textarea { width: 100%; min-height: 42px; max-height: 180px; resize: none; border: 0; padding: 5px 2px 8px; outline: none; color: var(--ink); background: transparent; font-size: 14px; line-height: 1.5; }
.composer textarea::placeholder { color: #aaa8a0; }
.composer-footer { display: flex; align-items: center; justify-content: space-between; }
.composer-tools { display: flex; align-items: center; gap: 8px; }
.circle-button, .send-button { width: 31px; height: 31px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 9px; background: transparent; color: var(--muted); font-size: 18px; }
.circle-button:disabled { opacity: .5; }
.send-button { border-color: var(--accent); color: var(--white); background: var(--accent); font-size: 17px; cursor: pointer; }
.send-button:disabled { border-color: var(--line); color: #aaa8a0; background: #efeee9; cursor: default; }
.mode-switch { display: flex; align-items: center; gap: 2px; border: 1px solid var(--line); border-radius: 9px; padding: 2px; background: #f6f5f1; }
.mode-button { height: 25px; border: 0; border-radius: 6px; padding: 0 9px; color: var(--muted); background: transparent; font-size: 10px; font-weight: 650; cursor: pointer; }
.mode-button.active { color: var(--ink); background: var(--white); box-shadow: 0 1px 4px rgba(20,20,18,.08); }
.composer-note { margin-top: 8px; margin-bottom: 0; color: var(--soft); font-size: 9px; text-align: center; }
.mobile-only { display: none; }
.mobile-scrim { position: fixed; inset: 0; z-index: 19; background: rgba(18,22,20,.34); backdrop-filter: blur(2px); }

@media (max-width: 860px) {
  .login-shell { grid-template-columns: 1fr; }
  .login-brand { min-height: 340px; padding: 30px; }
  .login-message h1 { font-size: 45px; }
  .login-message > p:last-child { margin-top: 18px; font-size: 14px; }
  .login-footnote { display: none; }
  .login-panel { min-height: calc(100vh - 340px); padding: 42px 24px; }
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; width: 280px; transform: translateX(-102%); transition: transform .22s ease; box-shadow: var(--shadow-lg); }
  .sidebar.open { transform: translateX(0); }
  .mobile-only { display: inline-grid; place-items: center; }
  .topbar { grid-template-columns: auto 1fr auto; gap: 10px; padding: 0 13px; }
  .topbar-title { min-width: 0; }
  .quiet-button { display: none; }
  .conversation { padding-left: 18px; padding-right: 18px; }
  .suggestion-grid { grid-template-columns: 1fr; max-width: 520px; }
  .suggestion-card { min-height: 82px; }
  .welcome-state { padding-top: 40px; }
  .composer-zone { padding-left: 12px; padding-right: 12px; }
}

@media (max-width: 560px) {
  .login-brand { min-height: 300px; padding: 24px; }
  .login-message h1 { font-size: 38px; }
  .login-message > p:last-child { display: none; }
  .login-panel { min-height: calc(100vh - 300px); }
  .workspace-main { grid-template-rows: 54px minmax(0,1fr) auto; }
  .topbar-actions .share-button { display: none; }
  .welcome-state h1 { font-size: 34px; }
  .welcome-copy { font-size: 13px; }
  .suggestion-card:nth-child(3) { display: none; }
  .message { grid-template-columns: 29px minmax(0,1fr); gap: 10px; }
  .message-avatar { width: 28px; height: 28px; border-radius: 8px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; transition-duration: .01ms !important; }
}
