:root {
  --bg:#ffffff;
  --bg-alt:#f4f7fb;
  --panel:#ffffff;
  --border:#dbe2ea;
  --border-strong:#c6d0db;
  --accent:#2563eb;
  --accent-rgb:37 99 235;
  --accent-soft:#e3f0ff;
  --text:#1e2935;
  --text-dim:#5b6b7d;
  --danger:#dc2626;
  --warn:#f59e0b;
  --ok:#059669;
  --radius:18px;
  --focus:0 0 0 3px rgba(var(--accent-rgb)/.35);
  font-family: system-ui,-apple-system,Roboto,Inter,Helvetica,Arial,sans-serif;
  color-scheme: light;
}

*{box-sizing:border-box;}
html,body{margin:0;padding:0;background:var(--bg-alt);color:var(--text);}
body{min-height:100vh;display:flex;flex-direction:column;}

.app-header{
  position:sticky;top:0;z-index:40;
  background:var(--panel);
  display:flex;align-items:center;justify-content:space-between;
  gap:1rem;padding:.8rem 1rem .7rem;
  border-bottom:1px solid var(--border);
}

.brand{display:flex;align-items:center;gap:.55rem;font-weight:600;font-size:1rem;}
.logo-icon{font-size:1.35rem;}
.logo-text{background:linear-gradient(90deg,#2563eb,#6366f1);-webkit-background-clip:text;color:transparent;}

.clock{font-size:.7rem;letter-spacing:.75px;padding:.25rem .55rem;border:1px solid var(--border);border-radius:999px;color:var(--text-dim);}

.container{
  width:100%;max-width:1080px;margin:0 auto;
  padding:1rem .9rem 2.2rem;
  display:grid;
  gap:1.1rem;
}

@media (min-width:880px){
  .container{grid-template-columns: minmax(0,1.05fr) minmax(340px,.9fr);}
}

.panel{
  background:var(--panel);
  border:1px solid var(--border);
  border-radius:var(--radius);
  padding:1rem .95rem 1.15rem;
  display:flex;flex-direction:column;gap:.85rem;
  position:relative;
  box-shadow:0 4px 18px -8px rgba(0,0,0,.08), 0 2px 6px -2px rgba(0,0,0,.06);
}

.panel-head{display:flex;justify-content:space-between;align-items:center;flex-wrap:wrap;gap:.6rem;}
.panel-title{margin:0;font-size:1rem;font-weight:600;display:flex;align-items:center;gap:.55rem;}
.badge{background:var(--accent-soft);color:var(--accent);font-size:.6rem;padding:.35rem .55rem;border-radius:999px;font-weight:600;letter-spacing:.6px;text-transform:uppercase;}

.helper{
  background:var(--bg-alt);
  border:1px solid var(--border);
  padding:.75rem .8rem;
  border-radius:14px;
  font-size:.75rem;line-height:1.35;
  color:var(--text-dim);
  display:flex;flex-direction:column;gap:.55rem;
}

.helper-eg{font-size:.68rem;color:var(--text);background:#eef4ff;padding:.4rem .55rem;border-radius:8px;font-weight:500;}
.chips{display:flex;gap:.5rem;flex-wrap:wrap;}
.chip{
  font:inherit;border:none;background:#eef4ff;
  color:#1e40af;font-size:.65rem;font-weight:600;
  padding:.45rem .7rem;border-radius:999px;
  cursor:pointer;
  transition:.2s;
}
.chip:hover{background:#dbe9ff;}

.messages{
  display:flex;flex-direction:column;gap:.65rem;
  max-height:260px;overflow:auto;scrollbar-width:thin;
  padding-right:.3rem;
}
.messages::-webkit-scrollbar{width:8px;}
.messages::-webkit-scrollbar-thumb{background:#d2dde8;border-radius:20px;}

.msg{
  max-width:80%;
  padding:.75rem .85rem;
  background:#f1f6fc;
  border:1px solid #e0e8f1;
  font-size:.8rem;
  line-height:1.35;
  border-radius:16px;
  position:relative;
  word-wrap:break-word;
  white-space:pre-wrap;
  backdrop-filter:blur(4px);
}
.msg small{
  position:absolute;top:-13px;left:8px;
  font-size:.52rem;letter-spacing:.8px;
  color:var(--text-dim);font-weight:600;
}
.msg.user{margin-left:auto;background:#2563eb;color:#fff;border-color:#1d57d9;}
.msg.user small{left:auto;right:8px;color:#1d57d9;}

.typing{font-size:.65rem;color:var(--text-dim);padding:.2rem .25rem;}

.input-bar{
  display:flex;gap:.65rem;align-items:flex-end;
  background:var(--bg-alt);
  border:1px solid var(--border);
  border-radius: 20px;
  padding:.65rem .75rem;
  position:sticky;bottom:0;
}

.input-bar textarea{
  flex:1;
  background:transparent;
  border:none;
  font:inherit;
  resize:none;
  min-height:46px;
  max-height:150px;
  line-height:1.35;
  color:var(--text);
  outline:none;
}

.input-ready{
  outline:2px solid #2563eb;
  outline-offset:2px;
  animation:readyPulse 1.7s ease-in-out infinite;
}
@keyframes readyPulse{
  0%{box-shadow:0 0 0 0 rgba(var(--accent-rgb)/.45);}
  70%{box-shadow:0 0 0 12px rgba(var(--accent-rgb)/0);}
  100%{box-shadow:0 0 0 0 rgba(var(--accent-rgb)/0);}
}

.input-buttons{display:flex;gap:.55rem;align-items:center;}

.btn{
  font:inherit;
  cursor:pointer;
  border:none;
  padding:.75rem 1.05rem;
  border-radius:12px;
  font-weight:600;
  font-size:.72rem;
  display:inline-flex;
  gap:.45rem;
  align-items:center;
  justify-content:center;
  background:#e5ecf3;
  color:#1e2935;
  transition:.18s;
}
.btn:hover{background:#d6e3ef;}
.btn:focus-visible{outline:none;box-shadow:var(--focus);}
.btn.primary{
  background:linear-gradient(90deg,#2563eb,#4f46e5);
  color:#fff;
  box-shadow:0 4px 14px -4px rgba(var(--accent-rgb)/.55);
}
.btn.primary:hover{filter:brightness(1.06);}
.btn.icon{padding:.75rem;width:52px;height:52px;aspect-ratio:1/1;}
.btn.danger{background:#fee2e2;color:#b91c1c;}
.btn.danger:hover{background:#fecaca;}
.btn.subtle{background:#f1f6fc;color:#475569;}
.btn.subtle:hover{background:#e3eef8;}

#micBtn.listening{
  background:#059669;
  color:#fff;
  animation:pulse 1.35s infinite;
}
@keyframes pulse{
  0%{box-shadow:0 0 0 0 rgba(5 150 105 / .55);}
  70%{box-shadow:0 0 0 14px rgba(5 150 105 / 0);}
  100%{box-shadow:0 0 0 0 rgba(5 150 105 / 0);}
}

.hint{
  font-size:.6rem;
  color:var(--text-dim);
  letter-spacing:.5px;
  margin-top:.15rem;
}

.dev-panel{
  background:#fff;
  border:1px dashed var(--border-strong);
  padding:.6rem .7rem;
  border-radius:14px;
  font-size:.62rem;
  line-height:1.25;
  color:#334155;
  max-height:200px;
  overflow:auto;
}
.dev-panel summary{
  cursor:pointer;
  font-weight:600;
  font-size:.65rem;
  margin-bottom:.4rem;
}

.task-list{
  list-style:none;
  margin:0;
  padding:0;
  display:flex;flex-direction:column;
  gap:.65rem;
}

.task{
  display:flex;align-items:flex-start;gap:.7rem;
  background:var(--bg-alt);
  border:1px solid var(--border);
  border-radius:14px;
  padding:.7rem .75rem .65rem;
  position:relative;
  transition:.18s;
}
.task:hover{background:#ecf3fa;}
.task.done{opacity:.55;text-decoration:line-through;}
.task input[type=checkbox]{
  margin-top:.2rem;
  width:20px;height:20px;
  accent-color:var(--accent);
  cursor:pointer;
}
.task-title{font-size:.8rem;font-weight:600;line-height:1.25;}
.task-meta{display:flex;flex-wrap:wrap;gap:.35rem;margin-top:.35rem;}
.tag{
  background:#e6eef7;
  padding:.3rem .55rem;
  border-radius:999px;
  font-size:.55rem;
  font-weight:600;
  letter-spacing:.5px;
  color:#4a5a6b;
  text-transform:uppercase;
}
.tag.time{background:#dbe9ff;color:#1e40af;}
.tag.today{background:#dcfce7;color:#166534;}
.tag.past{background:#fee2e2;color:#991b1b;}
.task-actions{
  position:absolute;top:6px;right:6px;
  display:flex;gap:.4rem;
}
.task-actions button{
  background:#ffffff;
  border:1px solid var(--border);
  font-size:.55rem;
  font-weight:600;
  padding:.35rem .55rem;
  border-radius:8px;
  cursor:pointer;
  color:#475569;
}
.task-actions button:hover{background:#f0f5fa;}
.task-actions button.del{background:#fee2e2;border-color:#fca5a5;color:#b91c1c;}
.task-actions button.del:hover{background:#fecaca;}

.empty{font-size:.65rem;color:var(--text-dim);padding:.3rem .2rem;}

.footer{
  margin-top:auto;
  padding:1.1rem 1rem 2.4rem;
  text-align:center;
  font-size:.6rem;
  color:#6b7b8d;
  line-height:1.4;
}

.toast-wrap{
  position:fixed;
  top:1rem;
  left:50%;
  transform:translateX(-50%);
  display:flex;
  flex-direction:column;
  gap:.55rem;
  z-index:300;
  max-width:min(460px,90%);
  pointer-events:none;
}

.toast{
  background:#ffffff;
  border:1px solid var(--border);
  padding:.65rem .75rem;
  border-radius:14px;
  font-size:.65rem;
  line-height:1.35;
  display:flex;
  gap:.55rem;
  font-weight:500;
  color:#1e2935;
  box-shadow:0 8px 24px -10px rgba(0,0,0,.13),0 3px 8px -3px rgba(0,0,0,.08);
  animation:toastIn .45s cubic-bezier(.45,.85,.25,1);
}
.toast.ok{border-color:#bbf7d0;background:#f0fdf4;}
.toast.err{border-color:#fecaca;background:#fef2f2;}
@keyframes toastIn{
  from{opacity:0;transform:translate(-50%,-10px) scale(.95);}
  to{opacity:1;transform:translate(-50%,0) scale(1);}
}

.modal-overlay{
  position:fixed;inset:0;
  background:rgba(30,41,53,.25);
  backdrop-filter:blur(6px);
  display:flex;align-items:center;justify-content:center;
  padding:1.2rem .9rem;
  z-index:500;
  animation:fadeIn .25s ease;
}
@keyframes fadeIn{
  from{opacity:0;transform:translateY(10px);}
  to{opacity:1;transform:translateY(0);}
}

.modal{
  background:#ffffff;
  border:1px solid var(--border);
  border-radius:24px;
  padding:1.05rem 1.1rem 1.2rem;
  width:min(440px,100%);
  display:flex;flex-direction:column;gap:.9rem;
  max-height:80vh;
  overflow:auto;
  box-shadow:0 15px 40px -10px rgba(0,0,0,.15);
}

.modal h3{margin:0;font-size:.95rem;font-weight:600;}
.modal .field{display:flex;flex-direction:column;gap:.45rem;}
.modal label{font-size:.6rem;font-weight:600;letter-spacing:.6px;text-transform:uppercase;color:#4b5c6d;}

.modal input[type=text],
.modal input[type=datetime-local],
.modal textarea{
  width:100%;
  font:inherit;
  background:#f1f6fc;
  border:1px solid var(--border);
  padding:.65rem .7rem;
  border-radius:12px;
  outline:none;
  font-size:.78rem;
  color:var(--text);
  resize:vertical;
  min-height:42px;
}
.modal input:focus,
.modal textarea:focus{border-color:var(--accent);background:#eef6ff;box-shadow:var(--focus);}

.modal-actions{display:flex;gap:.7rem;flex-wrap:wrap;}
.modal-actions .btn{flex:1;}

:focus-visible{outline:none;box-shadow:var(--focus);}

@media (max-width:660px){
  .panel-chat{order:1;}
  .panel-tasks{order:2;}
  .messages{max-height:220px;}
  .btn.icon{width:50px;height:50px;padding:.7rem;}
  .task-actions{gap:.25rem;}
}