@import url("https://fonts.googleapis.com/css2?family=Fraunces:ital,opsz,wght@0,9..144,300;0,9..144,400;0,9..144,600;0,9..144,700;1,9..144,300;1,9..144,400&family=DM+Sans:opsz,wght@9..40,400;9..40,500;9..40,600&display=swap");

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --display: 'Fraunces', Georgia, serif;
  --body: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --bg: #f6f5f1;
  --surface: #ffffff;
  --border: #ddd9d1;
  --border-light: #eceae4;
  --text: #1c1b18;
  --text-mid: #4a4640;
  --text-muted: #8a857d;
  --text-faint: #c2bdb4;
  --green: #2c5530;
  --green-hover: #1e3d22;
  --green-light: #e6efe7;
  --olive: #6b7c3a;
  --danger: #b91c1c;
  --radius: 6px;
  --transition: 150ms ease;
}

body {
  font-family: var(--body);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  font-size: 15px;
  line-height: 1.5;
}

/* ═══ TOP NAV ═══ */

.top-nav {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 1.25rem;
  height: 46px;
  padding: 0 2rem;
  background: var(--bg);
  border-bottom: 1px solid var(--border-light);
}

.top-nav .logo {
  font-family: var(--display);
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
  margin-right: auto;
  letter-spacing: -0.02em;
}

.logo-icon {
  vertical-align: -0.25em;
  margin-right: 0.2rem;
  border-radius: 4px;
}

.top-nav .logo .sub {
  font-family: var(--body);
  font-weight: 400;
  font-size: 0.65rem;
  color: var(--text-faint);
  margin-left: 0.5rem;
  letter-spacing: 0;
}

.top-nav a {
  font-size: 0.78rem;
  color: var(--text-muted);
  text-decoration: none;
  transition: color var(--transition);
}

.top-nav a:hover { color: var(--text); }
.top-nav a.active { color: var(--text); font-weight: 600; }

/* ═══ LAYOUT ═══ */

main {
  max-width: 660px;
  margin: 0 auto;
  padding: 2.5rem 2rem 4rem;
}

/* ═══ SHOULDS ═══ */

.phase {
  margin-bottom: 1.75rem;
}

.phase-header {
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
  padding: 0 0 0.35rem;
  cursor: pointer;
  user-select: none;
  border-bottom: 2px solid var(--border-light);
}

.phase-name {
  font-family: var(--body);
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.phase-count {
  font-size: 0.6rem;
  font-weight: 400;
  color: var(--text-faint);
}

.phase-add {
  background: none;
  border: none;
  color: var(--text-faint);
  font-size: 0.85rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 0.15rem;
  margin-left: auto;
  opacity: 0;
  transition: all var(--transition);
}

.phase-header:hover .phase-add { opacity: 1; }
.phase-add:hover { color: var(--green); }

/* Empty phases */
.phase.empty .phase-shoulds { display: none; }
.phase.empty { margin-bottom: 0.3rem; }
.phase.empty .phase-header { border-bottom-color: transparent; padding-bottom: 0.15rem; }
.phase.empty .phase-name { color: var(--border); }
.phase.empty:hover .phase-name { color: var(--text-faint); }

/* Shoulds container */
.phase-shoulds {
  counter-reset: should;
}

.should {
  display: flex;
  align-items: flex-start;
  position: relative;
  padding: 0.4rem 0;
  padding-left: 2rem;
  border-bottom: 1px solid var(--border-light);
}

.should:last-child { border-bottom: none; }

/* Number marker */
.should::before {
  content: counter(should, decimal-leading-zero);
  counter-increment: should;
  position: absolute;
  left: 0;
  top: 0.55rem;
  font-family: var(--body);
  font-size: 0.6rem;
  font-weight: 500;
  color: var(--olive);
  opacity: 0.5;
  width: 1.4rem;
  text-align: right;
  letter-spacing: -0.02em;
}

/* The should text */
.should-text {
  flex: 1;
  background: none;
  border: none;
  color: var(--text-mid);
  font-family: var(--display);
  font-size: 1.05rem;
  font-weight: 300;
  font-optical-sizing: auto;
  line-height: 1.55;
  padding: 0;
  resize: none;
  outline: none;
  overflow: hidden;
  min-height: 1.55em;
  letter-spacing: -0.005em;
}

.should-text:focus {
  color: var(--text);
  background: rgba(108, 124, 58, 0.04);
  margin-left: -0.3rem;
  padding-left: 0.3rem;
  border-radius: 3px;
}

/* Save indicator */
.save-indicator {
  position: fixed;
  top: 12px;
  right: 2rem;
  font-family: var(--body);
  font-size: 0.6rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--text-faint);
  opacity: 0;
  transition: opacity 0.3s ease;
  z-index: 60;
}

.save-indicator.saving { opacity: 1; color: var(--olive); }
.save-indicator.saved { opacity: 1; }

.should-text::placeholder {
  color: var(--text-faint);
  font-style: italic;
  font-weight: 300;
}

.should-text.new-input {
  color: var(--text-muted);
}

.should-text.new-input:focus {
  color: var(--text);
}

/* Actions */
.should-actions {
  display: flex;
  flex-shrink: 0;
  opacity: 0;
  transition: opacity var(--transition);
  padding-top: 0.15rem;
}

.should:hover .should-actions { opacity: 1; }

.should-delete {
  background: none;
  border: none;
  color: var(--text-faint);
  cursor: pointer;
  font-size: 0.8rem;
  padding: 0.15rem 0.25rem;
  line-height: 1;
  transition: color var(--transition);
}

.should-delete:hover { color: var(--danger); }

.should-keep {
  background: none;
  border: none;
  color: var(--green);
  cursor: pointer;
  font-size: 0.8rem;
  padding: 0.15rem 0.25rem;
  line-height: 1;
  font-weight: 700;
}

.should-keep:hover { color: var(--green-hover); }

/* Drag handle */
.should-handle {
  flex-shrink: 0;
  width: 1rem;
  font-size: 0.75rem;
  color: var(--text-faint);
  cursor: grab;
  padding-top: 0.15rem;
  text-align: center;
  opacity: 0;
  transition: opacity var(--transition), color var(--transition);
  user-select: none;
  margin-right: 0.15rem;
}

.should:hover .should-handle { opacity: 0.7; }
.should-handle:hover { opacity: 1 !important; color: var(--olive); }
.should-handle:active { cursor: grabbing; }

/* Drag states */
.should.dragging {
  opacity: 0.3;
}

.should-placeholder {
  height: 2px;
  background: var(--olive);
  border-radius: 1px;
  margin: 0.15rem 0 0.15rem 2rem;
  opacity: 0.6;
}

.should.suggestion .should-text { color: var(--green); font-style: italic; }
.should.suggestion::before { color: var(--green); opacity: 0.3; }
.should.suggestion .should-actions { opacity: 1; }

/* ═══ CHAT ═══ */

.chat-wrap {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 46px - 5rem);
}

.chat-messages { flex: 1; overflow-y: auto; padding: 0.5rem 0; }

.msg { margin-bottom: 1.25rem; }

.msg-who {
  font-family: var(--body);
  font-size: 0.6rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-faint);
  margin-bottom: 0.15rem;
}

.msg-who.tony { color: var(--olive); }

.msg-body {
  font-family: var(--display);
  font-size: 1.02rem;
  font-weight: 300;
  color: var(--text-mid);
  line-height: 1.65;
}

.msg-body strong { color: var(--text); font-weight: 600; }

.chat-input {
  display: flex;
  gap: 0.5rem;
  padding: 0.75rem 0;
  border-top: 1px solid var(--border-light);
}

.chat-input input {
  flex: 1;
  font-family: var(--display);
  font-size: 0.95rem;
  font-weight: 300;
  padding: 0.5rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  outline: none;
}

.chat-input input:focus { border-color: var(--green); }

.chat-input button {
  font-family: var(--body);
  font-size: 0.78rem;
  font-weight: 500;
  padding: 0.5rem 1rem;
  border-radius: var(--radius);
  border: none;
  background: var(--green);
  color: #fff;
  cursor: pointer;
  transition: background var(--transition);
}

.chat-input button:hover { background: var(--green-hover); }

/* ═══ SETTINGS ═══ */

.settings-section { margin-bottom: 2.5rem; }

.settings-section h3 {
  font-family: var(--display);
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin-bottom: 0.1rem;
}

.settings-hint {
  font-size: 0.72rem;
  color: var(--text-faint);
  margin-bottom: 0.75rem;
}

.acronym-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.35rem 0;
  border-bottom: 1px solid var(--border-light);
  font-family: var(--display);
  font-size: 0.9rem;
  font-weight: 300;
  color: var(--text-muted);
}

.acronym-row button {
  background: none;
  border: none;
  color: var(--text-faint);
  font-family: var(--body);
  font-size: 0.62rem;
  cursor: pointer;
}

.acronym-row button:hover { color: var(--danger); }

.ai-suggestion {
  background: var(--green-light);
  border: 1px solid #d1e0d3;
  border-radius: var(--radius);
  padding: 0.55rem 0.7rem;
  margin-bottom: 0.4rem;
}

.ai-suggestion p {
  font-family: var(--display);
  font-size: 0.9rem;
  font-weight: 300;
  color: var(--text-mid);
}

.ai-suggestion button {
  background: var(--green);
  color: #fff;
  border: none;
  font-family: var(--body);
  font-size: 0.68rem;
  font-weight: 600;
  padding: 0.25rem 0.6rem;
  border-radius: 4px;
  cursor: pointer;
  margin-top: 0.3rem;
}

/* Poof animation */
@keyframes poof {
  0% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(1.05); }
  100% { opacity: 0; transform: scale(0.3); height: 0; padding: 0; margin: 0; border: none; overflow: hidden; }
}

.ai-suggestion.poof {
  animation: poof 0.4s ease forwards;
  pointer-events: none;
}

.btn {
  font-family: var(--body);
  font-size: 0.75rem;
  font-weight: 500;
  padding: 0.35rem 0.8rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition);
}

.btn:hover { border-color: #bbb; color: var(--text); }

/* ═══ LOGIN ═══ */

body.login-page {
  background: linear-gradient(160deg, #161a22 0%, #0a0d12 100%);
  color: #c8c5cc;
}

body.login-page::before {
  content: "";
  position: fixed;
  inset: 0;
  opacity: 0.02;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  pointer-events: none;
}

.login-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 2rem;
  position: relative;
  z-index: 1;
}

.login-icon {
  margin-bottom: 1rem;
  filter: drop-shadow(0 0 20px rgba(165, 188, 57, 0.08));
}

.login-wrap h1 {
  font-family: var(--display);
  font-size: 1.6rem;
  font-weight: 700;
  color: #eae8ed;
  margin-bottom: 0.2rem;
  letter-spacing: -0.03em;
}

.login-wrap .login-sub {
  font-family: var(--body);
  font-size: 0.62rem;
  color: #605c66;
  margin-bottom: 1.75rem;
  min-height: 1em;
}

.login-wrap form { width: 100%; max-width: 280px; }

.login-wrap label {
  display: block;
  font-size: 0.58rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: #605c66;
  margin-bottom: 0.3rem;
  text-transform: uppercase;
}

.login-wrap input {
  width: 100%;
  margin-bottom: 0.75rem;
  padding: 0.55rem 0.7rem;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: var(--radius);
  color: #ddd;
  font-family: var(--body);
  font-size: 0.85rem;
  outline: none;
}

.login-wrap input:focus {
  border-color: #A5BC39;
  box-shadow: 0 0 0 2px rgba(165,188,57,0.15);
}

.login-wrap button {
  width: 100%;
  padding: 0.6rem;
  background: #A5BC39;
  color: #0c0d10;
  border: none;
  border-radius: var(--radius);
  font-family: var(--body);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  margin-top: 0.25rem;
}

.login-wrap button:hover { background: #b5cc48; }

.login-wrap .error {
  color: #ef4444;
  font-size: 0.72rem;
  text-align: center;
  min-height: 1rem;
  margin-bottom: 0.15rem;
}

.login-tagline {
  position: fixed;
  bottom: 1.5rem;
  left: 0;
  right: 0;
  text-align: center;
  font-family: var(--body);
  font-size: 0.52rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #605c66;
  opacity: 0.4;
}

/* ═══ TOAST ═══ */

.toast-container { position: fixed; bottom: 1rem; right: 1rem; z-index: 200; }

.toast {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.4rem 0.75rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  margin-top: 0.35rem;
}

.toast.error { border-color: var(--danger); color: var(--danger); }

/* ═══ LOADER ═══ */

.loader {
  text-align: center;
  padding: 3rem;
  font-family: var(--display);
  font-size: 0.95rem;
  font-weight: 300;
  color: var(--text-faint);
  font-style: italic;
}

@media (max-width: 600px) {
  main { padding: 1.75rem 1.25rem 3rem; }
  .top-nav { padding: 0 1.25rem; gap: 0.75rem; }
  .phase-name { font-size: 0.62rem; }
  .should-text { font-size: 0.95rem; }
  .should { padding-left: 1.5rem; }
  .should::before { font-size: 0.55rem; width: 1rem; }
}
