*,*::before,*::after{box-sizing:border-box;margin:0;padding:0}
:root{
  --bg:#0a0a0a;--surface:#161616;--surface2:#1e1e1e;--border:#2a2a2a;
  --text:#e0e0e0;--muted:#888;--accent:#e05030;--accent-hover:#c04020;
  --green:#2ecc71;--red:#e74c3c;
  --blue:#3b82f6;--purple:#8b5cf6;--teal:#14b8a6;
}
body{font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;background:var(--bg);color:var(--text);line-height:1.5}
a{color:var(--accent);text-decoration:none}
a:hover{text-decoration:underline}

/* Nav */
nav{display:flex;align-items:center;justify-content:space-between;padding:1rem 2rem;background:var(--surface);border-bottom:1px solid var(--border)}
.brand{font-weight:700;font-size:1.2rem;color:var(--text)}
.brand:hover{text-decoration:none}
.nav-links{display:flex;gap:1.5rem}
.nav-links a{color:var(--muted);font-size:0.9rem}
.nav-links a:hover{color:var(--text)}

/* Layout */
main{max-width:740px;margin:2rem auto;padding:0 1.5rem}
h1{font-size:1.8rem;margin-bottom:0.5rem}
h2{font-size:1.1rem;margin-bottom:0.5rem;color:var(--muted)}
.muted{color:var(--muted);margin-bottom:1rem;font-size:0.9rem}
.subtitle{color:var(--muted);margin-bottom:2rem}
.container{display:flex;flex-direction:column;gap:1rem}
.card{background:var(--surface);border:1px solid var(--border);border-radius:10px;padding:1.25rem}

/* Profile */
dl{display:grid;grid-template-columns:auto 1fr;gap:0.4rem 1rem}
dt{color:var(--muted);font-size:0.85rem}
dd{font-size:0.95rem}

/* Buttons */
.btn{display:inline-block;padding:0.5rem 1.2rem;background:var(--accent);color:#fff;border:none;border-radius:6px;cursor:pointer;font-size:0.85rem;font-weight:500;transition:background .15s}
.btn:hover{background:var(--accent-hover);text-decoration:none}
.btn:disabled{opacity:0.6;cursor:default}

/* Auth */
.auth-container{max-width:380px;margin:4rem auto;text-align:center}
.auth-container h1{font-size:2.2rem}
.tabs{display:flex;gap:0;margin-bottom:1.5rem;border-bottom:1px solid var(--border)}
.tab{flex:1;padding:0.6rem;background:none;border:none;color:var(--muted);cursor:pointer;font-size:0.95rem;border-bottom:2px solid transparent}
.tab.active{color:var(--text);border-bottom-color:var(--accent)}
.auth-form{text-align:left}
.field{margin-bottom:0.85rem}
.field label{display:block;font-size:0.8rem;color:var(--muted);margin-bottom:0.25rem;text-transform:uppercase;letter-spacing:0.03em}
.field input,.field select{width:100%;padding:0.55rem 0.75rem;background:var(--surface);border:1px solid var(--border);border-radius:6px;color:var(--text);font-size:0.95rem}
.field input:focus,.field select:focus{outline:none;border-color:var(--accent)}
.auth-form button[type=submit]{width:100%;padding:0.65rem;margin-top:0.5rem}
.field-checkbox label{display:flex;align-items:flex-start;gap:0.5rem;font-size:0.85rem;color:var(--muted);cursor:pointer;line-height:1.4;text-transform:none;letter-spacing:normal}
.field-checkbox input[type=checkbox]{width:auto;margin-top:0.2rem;flex-shrink:0}
.field-checkbox a{color:var(--accent)}
.error{color:var(--red);font-size:0.85rem;min-height:1.2em;margin-bottom:0.5rem}

/* ── Schedule cards ── */
.schedule-card{transition:opacity .2s}
.schedule-card.disabled{opacity:0.45}
.schedule-card.disabled .schedule-body{pointer-events:none}

.schedule-header{display:flex;justify-content:space-between;align-items:center;margin-bottom:1rem}
.schedule-title{display:flex;align-items:center;gap:0.5rem}
.schedule-icon{font-size:1.2rem}
.schedule-header h3{font-size:1rem;font-weight:600}

.schedule-body{display:flex;flex-direction:column;gap:0.85rem}

.schedule-controls{display:grid;grid-template-columns:1fr 1fr;gap:1rem;align-items:start}
.field-time input[type=time]{width:100%}
.field-variance{display:flex;flex-direction:column}
.variance-wrap{display:flex;align-items:center;gap:0.5rem}
.variance-wrap input[type=range]{flex:1;height:6px;-webkit-appearance:none;appearance:none;background:var(--border);border-radius:3px;outline:none}
.variance-wrap input[type=range]::-webkit-slider-thumb{-webkit-appearance:none;width:16px;height:16px;border-radius:50%;background:var(--muted);cursor:pointer;border:none;transition:background .15s}
.variance-wrap input[type=range].has-value::-webkit-slider-thumb{background:var(--accent)}
.variance-label{font-size:0.8rem;color:var(--muted);white-space:nowrap;min-width:3.5em}

/* Day picker */
.day-picker{display:flex;gap:0.3rem}
.day-btn{flex:1;padding:0.4rem 0;background:var(--surface2);border:1px solid var(--border);border-radius:6px;color:var(--muted);cursor:pointer;font-size:0.8rem;font-weight:500;text-align:center;transition:all .15s}
.day-btn:hover{border-color:var(--muted)}
.day-btn.active{background:var(--blue);border-color:var(--blue);color:#fff}
.day-btn.active:nth-child(6){background:var(--purple);border-color:var(--purple)}
.day-btn.active:nth-child(7){background:var(--purple);border-color:var(--purple)}

/* Next fire badges */
.schedule-footer{display:flex;justify-content:space-between;align-items:center}
.next-fires{display:flex;align-items:center;gap:0.4rem;flex-wrap:wrap}
.next-label{font-size:0.75rem;color:var(--muted);margin-right:0.1rem}
.next-badge{display:inline-flex;align-items:center;padding:0.25rem 0.65rem;background:linear-gradient(135deg,rgba(20,184,166,0.15),rgba(59,130,246,0.12));border:1px solid rgba(20,184,166,0.3);border-radius:20px;font-size:0.75rem;font-weight:600;color:var(--teal);cursor:default;letter-spacing:0.02em;transition:all .15s}
.next-badge:hover{background:linear-gradient(135deg,rgba(20,184,166,0.25),rgba(59,130,246,0.2));border-color:var(--teal);transform:translateY(-1px)}

/* Toggle switch */
.toggle{position:relative;display:inline-block;width:42px;height:24px;flex-shrink:0}
.toggle input{opacity:0;width:0;height:0}
.toggle-slider{position:absolute;cursor:pointer;top:0;left:0;right:0;bottom:0;background:var(--surface2);border:1px solid var(--border);border-radius:24px;transition:.2s}
.toggle-slider::before{content:"";position:absolute;height:18px;width:18px;left:2px;bottom:2px;background:var(--muted);border-radius:50%;transition:.2s}
.toggle input:checked+.toggle-slider{background:var(--green);border-color:var(--green)}
.toggle input:checked+.toggle-slider::before{transform:translateX(18px);background:#fff}

/* ── Goals page ── */
.goals-wide{max-width:960px}

.epoch-section{margin-bottom:0.5rem}
.epoch-header{display:flex;justify-content:space-between;align-items:center;flex-wrap:wrap;gap:0.75rem;margin-bottom:0.75rem}
.epoch-controls{display:flex;align-items:center;gap:0.5rem;flex-wrap:wrap}
.epoch-input{padding:0.4rem 0.6rem;background:var(--surface2);border:1px solid var(--border);border-radius:6px;color:var(--text);font-size:0.9rem}
.epoch-input:focus{outline:none;border-color:var(--accent)}
.btn-sm{padding:0.35rem 0.8rem;font-size:0.8rem}
.btn-secondary{background:var(--surface2);border:1px solid var(--border);color:var(--text)}
.btn-secondary:hover{background:var(--border)}
.epoch-explain{color:var(--muted);font-size:0.85rem;line-height:1.5;margin-bottom:0.5rem}
.epoch-explain strong{color:var(--text)}
.epoch-status{font-size:0.8rem;color:var(--muted);margin-top:0.5rem;padding:0.4rem 0.6rem;border-radius:4px;background:var(--surface2)}
.epoch-status.active{color:var(--blue);background:rgba(59,130,246,0.1);border:1px solid rgba(59,130,246,0.2)}

.goals-layout{display:grid;grid-template-columns:1fr 1fr;gap:1rem}
.goals-layout>.card{display:flex;flex-direction:column}
.goals-layout>.card .json-editor-field,
.goals-layout>.card #json-editor-wrap,
.goals-layout>.card #json-editor,
.goals-layout>.card textarea[rows]{flex:1}
@media(max-width:768px){.goals-layout{grid-template-columns:1fr}}

.goals-input-panel textarea{width:100%;padding:0.75rem;background:var(--surface2);border:1px solid var(--border);border-radius:6px;color:var(--text);font-family:inherit;font-size:0.9rem;resize:vertical;line-height:1.5}
.goals-input-panel textarea:focus{outline:none;border-color:var(--accent)}
.goals-input-footer{display:flex;align-items:center;gap:0.75rem;margin-top:0.75rem}
.parse-status{font-size:0.8rem;color:var(--muted)}
.parse-status.success{color:var(--green)}
.parse-status.warning{color:#e5a00d}
.parse-status.error{color:var(--red)}

.parse-feedback{display:flex;flex-direction:column;gap:0.5rem;margin-top:0.75rem}
.feedback-section h3{font-size:0.85rem;color:var(--text);margin-bottom:0.35rem}
.feedback-item{font-size:0.83rem;line-height:1.45;padding:0.55rem 0.75rem;border-radius:6px}
.feedback-error{background:rgba(231,76,60,0.1);border:1px solid rgba(231,76,60,0.25);color:#f08070}
.feedback-warning{background:rgba(229,160,13,0.1);border:1px solid rgba(229,160,13,0.25);color:#e5a00d}
.feedback-info{background:rgba(59,130,246,0.1);border:1px solid rgba(59,130,246,0.2);color:var(--blue)}

.goals-data-header{display:flex;justify-content:space-between;align-items:center;margin-bottom:0.75rem}
.goals-data-header .toggle{display:flex;align-items:center;gap:0.5rem;width:auto}
.toggle-label{font-size:0.8rem;color:var(--muted);white-space:nowrap;position:relative}

#json-editor,.json-editor-field{width:100%;padding:0.75rem;background:var(--bg);border:1px solid var(--border);border-radius:6px;color:var(--text);font-family:"SF Mono",Monaco,Consolas,monospace;font-size:0.8rem;resize:vertical;line-height:1.5;tab-size:2}
#json-editor:focus,.json-editor-field:focus{outline:none;border-color:var(--accent)}
#json-editor[readonly],.json-editor-field[readonly]{opacity:0.7;cursor:default}
#json-editor.editable,.json-editor-field.editable{opacity:1;border-color:var(--blue)}
.json-editor-field.live-loading{border-color:var(--accent);opacity:0.5;transition:opacity 0.2s}

.json-error{color:var(--red);font-size:0.8rem;min-height:1.2em;margin-top:0.35rem}
.goals-data-footer{display:flex;align-items:center;gap:0.75rem;margin-top:0.75rem}
.save-status{font-size:0.8rem;color:var(--muted)}
.save-status.success{color:var(--green)}
.save-status.error{color:var(--red)}

.feedback-nudge{background:rgba(139,92,246,0.1);border:1px solid rgba(139,92,246,0.25);color:var(--purple)}

.summary-section{margin-top:0.5rem}
.summary-method{font-size:0.8rem;color:var(--muted);margin-bottom:0.75rem;font-style:italic}
.summary-table{width:100%;border-collapse:collapse;font-size:0.85rem}
.summary-table th{text-align:left;padding:0.4rem 0.6rem;border-bottom:1px solid var(--border);color:var(--muted);font-weight:500;font-size:0.75rem;text-transform:uppercase;letter-spacing:0.03em}
.summary-table td{padding:0.45rem 0.6rem;border-bottom:1px solid var(--surface2)}
.summary-label{color:var(--muted);font-weight:500}
.summary-table tr:last-child td{border-bottom:none}

/* ── Profile page ── */
.profile-form{display:flex;flex-direction:column;gap:1rem}
.profile-grid{display:grid;grid-template-columns:1fr 1fr;gap:1rem}
@media(max-width:600px){.profile-grid{grid-template-columns:1fr}}
.profile-footer{display:flex;align-items:center;gap:0.75rem;margin-top:0.5rem}
.field-hint{font-size:0.8rem;color:var(--muted);margin-top:0.2rem;display:block}

/* Methods sub-sections */
.methods-sections{display:flex;flex-direction:column;gap:1.25rem;margin-bottom:1rem}
.method-section h3{font-size:0.9rem;font-weight:600;color:var(--text);margin-bottom:0.5rem;padding-bottom:0.3rem;border-bottom:1px solid var(--border)}

/* Memories */
.memories-list{display:flex;flex-direction:column;gap:0.4rem}
.memory-item{display:flex;align-items:flex-start;justify-content:space-between;gap:0.75rem;padding:0.6rem 0.75rem;background:var(--surface2);border-radius:6px;border:1px solid var(--border)}
.memory-content{display:flex;flex-wrap:wrap;align-items:baseline;gap:0.4rem;flex:1;min-width:0}
.memory-category{font-size:0.7rem;font-weight:600;text-transform:uppercase;letter-spacing:0.04em;color:var(--accent);background:rgba(224,80,48,0.1);padding:0.15rem 0.45rem;border-radius:3px;white-space:nowrap}
.memory-text{font-size:0.88rem;line-height:1.45;color:var(--text)}
.memory-date{font-size:0.75rem;color:var(--muted);white-space:nowrap;margin-left:auto}
.memory-delete{background:none;border:none;color:var(--muted);font-size:1.1rem;cursor:pointer;padding:0 0.3rem;line-height:1;opacity:0.5;transition:opacity .15s,color .15s}
.memory-delete:hover{opacity:1;color:var(--red)}

/* DnD section */
.dnd-section{margin-top:0.5rem}
.dnd-section h2{margin-bottom:0.25rem}
.dnd-section .muted{margin-bottom:0.75rem}
.dnd-row{display:flex;align-items:flex-end;gap:1rem;flex-wrap:wrap}
.dnd-row .toggle{align-self:center;margin-bottom:0.25rem}
.dnd-row .field{flex:1;min-width:100px;margin-bottom:0}
.dnd-row .btn{align-self:flex-end;margin-bottom:0.15rem}

/* ── Landing page ── */
.hero{text-align:center;padding:4rem 0 3rem}
.hero h1{font-size:3rem;font-weight:800;letter-spacing:-0.02em;margin-bottom:0.5rem}
.hero-tagline{font-size:1.3rem;color:var(--accent);font-weight:600;margin-bottom:1rem}
.hero-sub{color:var(--muted);font-size:1.05rem;max-width:540px;margin:0 auto;line-height:1.7}

.how-it-works{padding:2rem 0}
.how-it-works h2,.features h2,.personality h2,.cta-section h2{
  font-size:1.4rem;font-weight:700;color:var(--text);margin-bottom:1.25rem;text-align:center
}
.steps{display:flex;flex-direction:column;gap:1rem}
.step{position:relative;padding-left:3.5rem}
.step-number{
  position:absolute;left:1.25rem;top:1.25rem;
  font-size:1.1rem;font-weight:800;color:var(--accent);
}
.step h3{font-size:1rem;font-weight:600;margin-bottom:0.35rem}
.step p{color:var(--muted);font-size:0.92rem;line-height:1.6}

.features{padding:2rem 0}
.feature-grid{display:grid;grid-template-columns:1fr 1fr;gap:1rem}
.feature-grid .card h3{font-size:0.95rem;font-weight:600;margin-bottom:0.3rem}
.feature-grid .card p{color:var(--muted);font-size:0.88rem;line-height:1.6}

.personality{padding:2rem 0}
.personality-card p{color:var(--muted);font-size:0.95rem;line-height:1.7;margin-bottom:0.75rem}
.personality-card p:last-child{margin-bottom:0}

.cta-section{text-align:center;padding:3rem 0 4rem}
.cta-quote{font-size:1.8rem;font-weight:800;margin-bottom:1.5rem;letter-spacing:-0.01em}
.blurred{filter:blur(5px);transition:filter .3s;cursor:pointer;user-select:none}
.blurred:hover{filter:blur(0)}
.btn-cta{
  display:inline-block;padding:0.85rem 2.5rem;font-size:1.1rem;font-weight:700;
  background:var(--accent);color:#fff;border-radius:8px;transition:background .15s,transform .1s
}
.btn-cta:hover{background:var(--accent-hover);text-decoration:none;transform:translateY(-1px)}

/* ── Metrics page ── */
.metrics-page{max-width:960px}

.metrics-stats{display:grid;grid-template-columns:repeat(auto-fit,minmax(120px,1fr));gap:1rem;margin-top:0.75rem}
.stat-item{display:flex;flex-direction:column;gap:0.15rem}
.stat-label{font-size:0.75rem;color:var(--muted);text-transform:uppercase;letter-spacing:0.03em}
.stat-value{font-size:1.3rem;font-weight:700}
.stat-value.over{color:var(--red)}
.stat-sub{font-size:0.75rem;color:var(--muted)}
.stat-sub.delta-up{color:var(--red)}
.stat-sub.delta-down{color:var(--green)}

.metrics-entry-grid{display:grid;grid-template-columns:1fr 1fr;gap:1rem}
@media(max-width:768px){.metrics-entry-grid{grid-template-columns:1fr}}

.metrics-entry-grid>.card{display:flex;flex-direction:column}
.metrics-form{display:flex;flex-direction:column;flex:1}
.metrics-form-row{display:grid;grid-template-columns:repeat(auto-fit,minmax(100px,1fr));gap:0.75rem;margin-bottom:0.75rem}
.metrics-form-spacer{flex:1}
.metrics-form-footer{display:flex;align-items:center;gap:0.75rem}
.metrics-form textarea{width:100%;padding:0.55rem 0.75rem;background:var(--surface);border:1px solid var(--border);border-radius:6px;color:var(--text);font-family:inherit;font-size:0.95rem;resize:vertical;line-height:1.5;margin-bottom:0.75rem}
.metrics-form textarea:focus{outline:none;border-color:var(--accent)}
.form-status{font-size:0.8rem;color:var(--muted)}
.form-status.success{color:var(--green)}
.form-status.error{color:var(--red)}

.metrics-table-wrap{overflow-x:auto}
.metrics-table{width:100%;border-collapse:collapse;font-size:0.85rem}
.metrics-table th{text-align:left;padding:0.4rem 0.5rem;border-bottom:1px solid var(--border);color:var(--muted);font-weight:500;font-size:0.75rem;text-transform:uppercase;letter-spacing:0.03em;white-space:nowrap}
.metrics-table td{padding:0.4rem 0.5rem;border-bottom:1px solid var(--surface2);white-space:nowrap}
.metrics-table .desc-cell{white-space:normal;max-width:200px;overflow:hidden;text-overflow:ellipsis}
.metrics-table tr:last-child td{border-bottom:none}

.source-badge{font-size:0.7rem;padding:0.15rem 0.4rem;border-radius:3px;background:var(--surface2);color:var(--muted);text-transform:uppercase;letter-spacing:0.03em}
.delete-btn{background:none;border:none;color:var(--muted);font-size:1.1rem;cursor:pointer;padding:0 0.3rem;line-height:1;opacity:0.5;transition:opacity .15s,color .15s}
.delete-btn:hover{opacity:1;color:var(--red)}

.recovery-green{color:#10b981}
.recovery-yellow{color:#f59e0b}
.recovery-red{color:#ef4444}

/* Footer */
footer{text-align:center;padding:2rem 1rem 1rem;font-size:0.8rem}
footer a{color:var(--muted)}
footer a:hover{color:var(--text)}

/* Privacy page */
.privacy-card{margin-bottom:0}
.privacy-card h2{color:var(--text);font-size:1rem;font-weight:600;margin-bottom:0.5rem}
.privacy-card p{color:var(--muted);font-size:0.9rem;line-height:1.6;margin-bottom:0.5rem}
.privacy-card p:last-child{margin-bottom:0}
.privacy-card ul{color:var(--muted);font-size:0.9rem;line-height:1.6;padding-left:1.25rem;margin-bottom:0.5rem}
.privacy-card a{color:var(--accent)}

/* ── Connect page ── */
.services-list{display:flex;flex-direction:column;gap:1rem}

.svc-card{display:flex;flex-direction:column;gap:1rem}
.svc-header{display:flex;align-items:flex-start;gap:1rem}
.svc-icon{width:40px;height:40px;flex-shrink:0;color:var(--accent);display:flex;align-items:center;justify-content:center}
.svc-icon svg{width:28px;height:28px}
.svc-info{flex:1;min-width:0}
.svc-info h3{font-size:1rem;font-weight:600;color:var(--text);margin-bottom:0}
.svc-desc{font-size:0.85rem;color:var(--muted)}

.svc-status-wrap{display:flex;flex-direction:column;align-items:flex-end;gap:0.2rem;flex-shrink:0}
.svc-status{font-size:0.8rem;font-weight:600;padding:0.2rem 0.6rem;border-radius:12px}
.status-ok{color:var(--green);background:rgba(46,204,113,0.1);border:1px solid rgba(46,204,113,0.25)}
.status-error{color:var(--red);background:rgba(231,76,60,0.1);border:1px solid rgba(231,76,60,0.25)}
.status-syncing{color:var(--blue);background:rgba(59,130,246,0.1);border:1px solid rgba(59,130,246,0.25)}
.status-none{color:var(--muted);background:var(--surface2);border:1px solid var(--border)}
.svc-sync-time{font-size:0.75rem;color:var(--muted)}
.svc-error{font-size:0.75rem;color:var(--red);max-width:200px;text-align:right}

.svc-actions{display:flex;align-items:center;gap:0.75rem;flex-wrap:wrap}

.cred-form{display:flex;flex-direction:column;gap:0.6rem;width:100%}
.cred-fields{display:flex;gap:0.5rem;flex-wrap:wrap}
.cred-fields input{flex:1;min-width:150px;padding:0.45rem 0.65rem;background:var(--surface2);border:1px solid var(--border);border-radius:6px;color:var(--text);font-size:0.9rem}
.cred-fields input:focus{outline:none;border-color:var(--accent)}
.cred-warning{font-size:0.8rem;color:var(--muted);margin:0}
.cred-hint{font-size:0.8rem;color:var(--muted);margin:0 0 0.5rem}
.cred-hint a{color:var(--accent)}
.cred-status{font-size:0.8rem}
.cred-status.error{color:var(--red)}
.cred-status.success{color:var(--green)}

.btn-danger{background:transparent;border:1px solid var(--red);color:var(--red)}
.btn-danger:hover{background:rgba(231,76,60,0.1)}

.toast{padding:0.75rem 1rem;border-radius:8px;font-size:0.9rem;margin-bottom:1rem;animation:fadeIn .2s ease}
.toast-error{background:rgba(231,76,60,0.1);border:1px solid rgba(231,76,60,0.25);color:#f08070}
@keyframes fadeIn{from{opacity:0;transform:translateY(-8px)}to{opacity:1;transform:translateY(0)}}

@media(max-width:600px){
  .hero h1{font-size:2.2rem}
  .hero-tagline{font-size:1.1rem}
  .feature-grid{grid-template-columns:1fr}
}
