:root {
  --ink: #0D0D0D;
  --soft: #F4F4F4;
  --muted: #8E8E8E;
  --line: #E5E5E5;
  --red: #E5484D;
  --bg: #FFFFFF;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: Inter, -apple-system, Segoe UI, Roboto, sans-serif; font-size: 16px; line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.error { color: var(--red); font-size: 14px; min-height: 1em; margin: 8px 0 0; }
button { font: inherit; color: inherit; cursor: pointer; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* login */
.screen { height: 100%; }
#login { display: flex; align-items: center; justify-content: center; padding: 16px; }
.login-card { width: 100%; max-width: 340px; text-align: center; }
.login-logo { width: 88px; height: 88px; }
.login-card h1 { margin: 8px 0 2px; font-size: 26px; }
.login-card input {
  width: 100%; margin: 18px 0 12px; padding: 13px 16px; font: inherit;
  border: 1px solid var(--line); border-radius: 14px; outline: none; background: var(--soft);
}
.login-card input:focus { border-color: var(--ink); background: #fff; }
.btn-primary {
  width: 100%; padding: 12px 16px; border: 0; border-radius: 999px;
  background: var(--ink); color: #fff; font-weight: 600;
}
.btn-primary:disabled { opacity: .5; cursor: default; }

/* app layout */
#app { display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px; border-bottom: 1px solid var(--line); background: #fff;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 17px; }
.brand img { width: 32px; height: 32px; }
.actions { display: flex; gap: 4px; }
.icon-btn {
  width: 40px; height: 40px; border: 0; border-radius: 50%; background: transparent;
  display: inline-flex; align-items: center; justify-content: center;
}
.icon-btn:hover { background: var(--soft); }
#scroller { flex: 1; overflow-y: auto; }
.messages { max-width: 780px; margin: 0 auto; padding: 16px 16px 24px; }
.empty {
  max-width: 780px; margin: 22vh auto 0; text-align: center; font-size: 28px; font-weight: 600; padding: 0 16px;
}

.msg-user { display: flex; justify-content: flex-end; margin-top: 16px; }
.msg-user .bubble {
  max-width: min(80%, 600px); background: var(--soft); padding: 10px 16px; border-radius: 20px;
  white-space: pre-wrap; word-wrap: break-word;
}
.voice-tag { display: flex; align-items: center; gap: 4px; font-size: 12px; color: var(--muted); margin-bottom: 2px; }
.voice-tag svg { width: 13px; height: 13px; }
.msg-bot { margin-top: 18px; }
.msg-tools { display: flex; gap: 2px; margin-top: 4px; }
.msg-tools button { border: 0; background: transparent; color: var(--muted); padding: 6px; border-radius: 8px; }
.msg-tools button:hover { background: var(--soft); color: var(--ink); }
.msg-tools svg { width: 17px; height: 17px; }
.thinking { display: flex; align-items: center; gap: 10px; color: var(--muted); margin-top: 14px; font-size: 15px; }
.dot-spin { width: 14px; height: 14px; border: 2px solid var(--line); border-top-color: var(--muted); border-radius: 50%; animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* markdown */
.md { word-wrap: break-word; }
.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }
.md p { margin: 0 0 10px; }
.md h1, .md h2, .md h3 { line-height: 1.3; margin: 18px 0 8px; }
.md h1 { font-size: 22px; } .md h2 { font-size: 19px; } .md h3 { font-size: 17px; }
.md ul, .md ol { padding-left: 22px; margin: 0 0 10px; }
.md li { margin: 3px 0; }
.md a { color: var(--ink); }
.md table { border-collapse: collapse; margin: 10px 0; display: block; overflow-x: auto; max-width: 100%; }
.md th, .md td { border: 1px solid var(--line); padding: 7px 11px; text-align: left; vertical-align: top; }
.md th { background: var(--soft); font-weight: 600; }
.md code { background: var(--soft); padding: 1px 5px; border-radius: 5px; font-size: 14px; }
.md blockquote { margin: 0 0 10px; padding-left: 12px; border-left: 3px solid var(--line); color: #444; }
.code {
  margin: 10px 0; background: var(--soft); border: 1px solid var(--line); border-radius: 12px; overflow: hidden;
}
.code-head { display: flex; justify-content: space-between; align-items: center; padding: 4px 6px 0 14px; font-size: 13px; color: var(--muted); }
.code-head button { border: 0; background: transparent; color: var(--muted); padding: 4px 8px; border-radius: 6px; font-size: 13px; }
.code-head button:hover { background: #fff; color: var(--ink); }
.code pre { margin: 0; padding: 6px 14px 12px; overflow-x: auto; }
.code pre code { background: none; padding: 0; font-size: 13.5px; line-height: 1.45; }

/* diagrams and artifacts */
.card { margin: 10px 0; border: 1px solid var(--line); border-radius: 16px; overflow: hidden; }
.card-head { display: flex; align-items: center; gap: 8px; padding: 6px 6px 6px 14px; background: var(--soft); font-size: 14px; font-weight: 600; }
.card-head .spacer { flex: 1; }
.card-head button { border: 0; background: transparent; padding: 6px 9px; border-radius: 8px; font-size: 13px; font-weight: 500; color: #444; }
.card-head button:hover { background: #fff; }
.card-body { background: #fff; padding: 12px; overflow-x: auto; }
.card-body svg { width: auto; height: auto; max-width: 100%; stroke: none; }
.card-body.mermaid-body svg { fill: initial; }
.card iframe { width: 100%; border: 0; display: block; min-height: 120px; background: #fff; }
.fullscreen-card { position: fixed; inset: 0; z-index: 50; background: #fff; display: flex; flex-direction: column; }
.fullscreen-card .card-body, .fullscreen-card iframe { flex: 1; height: 100% !important; }

/* composer */
.composer-wrap { padding: 8px 16px 14px; background: #fff; }
.composer {
  max-width: 780px; margin: 0 auto; display: flex; align-items: flex-end; gap: 6px;
  background: var(--soft); border-radius: 28px; padding: 6px 6px 6px 20px;
}
.composer textarea {
  flex: 1; border: 0; outline: none; background: transparent; resize: none; font: inherit;
  padding: 10px 0; max-height: 220px; line-height: 1.45;
}
.send-btn {
  width: 42px; height: 42px; border-radius: 50%; border: 0; background: var(--ink); color: #fff;
  display: inline-flex; align-items: center; justify-content: center; flex: none;
}
.send-btn:disabled { background: var(--muted); }
.hint { max-width: 780px; margin: 6px auto 0; text-align: center; font-size: 12px; }

/* voice */
.overlay { position: fixed; inset: 0; z-index: 40; background: #fff; display: flex; flex-direction: column; align-items: center; }
.voice-top { text-align: center; padding-top: 28px; }
.voice-title { font-weight: 600; font-size: 17px; }
.orb-wrap { flex: 1; display: flex; align-items: center; justify-content: center; }
.orb { position: relative; width: 300px; height: 300px; display: flex; align-items: center; justify-content: center; }
.ring { position: absolute; border-radius: 50%; background: var(--ink); transition: transform .12s linear; }
.r1 { width: 300px; height: 300px; opacity: .05; }
.r2 { width: 236px; height: 236px; opacity: .08; }
.r3 { width: 176px; height: 176px; opacity: .12; }
.core { position: relative; width: 120px; height: 120px; border-radius: 50%; background: #fff; box-shadow: 0 2px 12px rgba(0,0,0,.08);
  display: flex; align-items: center; justify-content: center; }
.bars { display: flex; gap: 4px; align-items: center; height: 44px; }
.bars i { display: block; width: 5px; height: 10px; border-radius: 3px; background: var(--ink); transition: height .1s linear; }
.spinner { width: 28px; height: 28px; border: 2.5px solid var(--line); border-top-color: var(--ink); border-radius: 50%; animation: spin .9s linear infinite; }
.voice-state { color: var(--muted); font-weight: 500; font-size: 15px; }
.captions { max-width: 620px; min-height: 96px; padding: 12px 24px; text-align: center; font-size: 18px; font-weight: 500; line-height: 1.45; }
.captions .you { color: var(--muted); font-weight: 400; font-size: 15px; }
.voice-controls { display: flex; gap: 48px; padding: 8px 0 40px; }
.round { border: 0; background: transparent; display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.round svg { width: 60px; height: 60px; padding: 18px; border-radius: 50%; background: var(--soft); color: var(--ink); }
.round.on svg { background: var(--ink); color: #fff; }
.round.end svg { background: var(--red); color: #fff; }

/* alarms */
#alarms { background: rgba(0,0,0,.25); justify-content: center; padding: 16px; }
.sheet { width: 100%; max-width: 520px; max-height: 92vh; overflow-y: auto; background: #fff; border-radius: 20px; padding: 18px 20px 20px; }
.sheet-head { display: flex; justify-content: space-between; align-items: center; }
.sheet-head h2 { margin: 0; font-size: 19px; }
.alarm-list { margin: 10px 0 18px; }
.alarm { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.alarm .time { font-size: 26px; font-weight: 300; letter-spacing: -1px; min-width: 120px; }
.alarm .info { flex: 1; font-size: 14px; }
.alarm .info .muted { font-size: 13px; }
.alarm button { border: 0; background: transparent; color: var(--muted); padding: 6px 10px; border-radius: 8px; font-size: 13px; }
.alarm button:hover { background: var(--soft); color: var(--red); }
.alarm-form h3 { margin: 0 0 10px; font-size: 16px; }
.alarm-form .row { display: flex; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.alarm-form input[type=time], .alarm-form input[type=text] {
  padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; font: inherit; background: #fff;
}
.alarm-form input[type=text] { flex: 1; min-width: 160px; }
.days { display: flex; gap: 6px; margin-bottom: 10px; flex-wrap: wrap; }
.days button { width: 42px; height: 36px; border-radius: 999px; border: 1px solid var(--line); background: #fff; font-size: 13px; }
.days button.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.modes { flex-direction: column; gap: 6px !important; font-size: 14px; }

@media (max-width: 600px) {
  .orb { transform: scale(.85); }
  .voice-controls { gap: 36px; }
  .hint { display: none; }
}
