:root {
  color-scheme: light;
  --bg: #f4f4f2;
  --panel: rgba(255,255,255,.82);
  --panel-solid: #fff;
  --ink: #101113;
  --muted: #71747a;
  --line: rgba(15,18,22,.09);
  --accent: #1768e5;
  --accent-soft: rgba(23,104,229,.1);
  --shadow: 0 20px 60px rgba(18,22,29,.08);
  --radius-window: 24px;
  --radius-control: 14px;
  --space-1: 8px;
  --space-2: 12px;
  --space-3: 16px;
  --space-4: 20px;
  --space-5: 24px;
  --space-6: 32px;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Helvetica Neue", sans-serif;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b0c0e;
  --panel: rgba(27,29,33,.82);
  --panel-solid: #1b1d21;
  --ink: #f5f5f3;
  --muted: #9b9da3;
  --line: rgba(255,255,255,.1);
  --accent: #61a0ff;
  --accent-soft: rgba(97,160,255,.13);
  --shadow: 0 22px 70px rgba(0,0,0,.3);
}

* { box-sizing: border-box; }
html, body { min-height: 100%; margin: 0; }
body { background: var(--bg); color: var(--ink); -webkit-font-smoothing: antialiased; }
button, input { font: inherit; }
button { color: inherit; cursor: pointer; }
[hidden] { display: none !important; }

.login { min-height: 100vh; display: grid; place-items: center; padding: 32px; background: radial-gradient(circle at 50% 0, var(--panel-solid), var(--bg) 58%); }
.login-card { width: min(390px, 100%); display: grid; gap: var(--space-4); padding: 42px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-window); box-shadow: var(--shadow); backdrop-filter: blur(30px); }
.login-logo { width: 102px; height: auto; }
.login-copy { margin: 10px 0 2px; }
.login-copy h1 { margin: 7px 0 6px; font-size: 34px; letter-spacing: -.045em; font-weight: 630; }
.login-copy p, .security-note { color: var(--muted); margin: 0; line-height: 1.45; }
.eyebrow, .tile-kicker { color: var(--muted); font-size: 10px; letter-spacing: .15em; font-weight: 750; }
label { display: grid; gap: 8px; font-size: 13px; font-weight: 620; }
input { width: 100%; height: 50px; padding: 0 15px; border: 1px solid var(--line); border-radius: var(--radius-control); background: var(--panel-solid); color: var(--ink); outline: none; }
input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.primary { height: 50px; border: 0; border-radius: var(--radius-control); background: var(--ink); color: var(--bg); font-weight: 680; }
.form-error { margin: -5px 0; color: #d33b32; font-size: 13px; }
.security-note { text-align: center; font-size: 11px; }

.workspace { min-height: 100vh; }
.topbar { position: sticky; top: 0; z-index: 20; height: 74px; display: flex; align-items: center; justify-content: space-between; padding: 0 32px; background: color-mix(in srgb, var(--bg) 82%, transparent); border-bottom: 1px solid var(--line); backdrop-filter: blur(28px); }
.brand { display: flex; align-items: center; gap: 14px; }
.brand img { width: 94px; }
.brand span { padding-left: 14px; border-left: 1px solid var(--line); color: var(--muted); font-size: 13px; }
.top-actions, .tile-tools { display: flex; align-items: center; gap: 8px; }
.connection { display: flex; align-items: center; gap: 8px; margin-right: 8px; color: var(--muted); font-size: 12px; }
.connection i { width: 7px; height: 7px; border-radius: 50%; background: #2bad62; box-shadow: 0 0 0 4px rgba(43,173,98,.12); }
.connection.is-offline i { background: #d05248; box-shadow: 0 0 0 4px rgba(208,82,72,.12); }
.quiet, .icon, .tile-size { border: 0; background: transparent; }
.quiet { height: 38px; padding: 0 14px; border-radius: 12px; color: var(--muted); font-size: 12px; font-weight: 620; }
.quiet:hover, .icon:hover, .tile-size:hover { background: var(--accent-soft); color: var(--accent); }
.icon, .tile-size { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; font-size: 18px; }
.tile-size { display: none; }

.main { width: min(1540px, 100%); margin: 0 auto; padding: var(--space-6) var(--space-6) 52px; }
.welcome { padding: var(--space-3) 4px var(--space-6); transition: opacity .25s, max-height .3s, padding .3s; }
.welcome h1 { margin: 7px 0 0; font-size: clamp(32px, 4vw, 54px); letter-spacing: -.052em; font-weight: 590; }
.welcome.is-hidden { opacity: 0; max-height: 0; overflow: hidden; padding: 0 4px; pointer-events: none; }
.dashboard { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); grid-auto-flow: dense; gap: var(--space-4); }
.tile { min-width: 0; min-height: 175px; align-self: start; grid-column: span 4; display: flex; flex-direction: column; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-window); box-shadow: var(--shadow); backdrop-filter: blur(24px); overflow: hidden; transition: transform .2s, border-color .2s, grid-column .2s; }
.tile[data-size="small"] { grid-column: span 3; }
.tile[data-size="medium"] { grid-column: span 4; }
.tile[data-size="large"] { grid-column: span 6; }
.tile[data-size="wide"] { grid-column: span 8; }
.tile-display[data-size="wide"] { grid-column: span 9; }
.tile-head { min-height: 72px; display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); padding: var(--space-3) var(--space-5); border-bottom: 1px solid var(--line); }
.tile-head h2 { margin: 4px 0 0; font-size: 18px; letter-spacing: -.025em; font-weight: 650; }
.tile-muted { margin: auto 20px 20px; color: var(--muted); line-height: 1.5; font-size: 13px; }
.calendar-tile-body { min-height: 100px; flex: 1; display: flex; flex-direction: column; justify-content: center; gap: 14px; padding: 20px; }
.calendar-tile-body .tile-muted { margin: 0; }
.calendar-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.calendar-button { min-height: 38px; padding: 0 14px; border: 1px solid var(--line); border-radius: 19px; background: var(--panel-solid); color: var(--ink); font-size: 12px; font-weight: 650; }
.calendar-button:hover { border-color: var(--accent); color: var(--accent); }
.task-tile-body { min-height: 100px; flex: 1; display: flex; flex-direction: column; justify-content: center; align-items: flex-start; gap: 14px; padding: 20px; }
.task-tile-body .tile-muted { margin: 0; }
.task-list { display: grid; gap: 9px; }
.task-row { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 14px 15px; border: 1px solid var(--line); border-radius: 15px; background: var(--panel-solid); }
.task-row div { min-width: 0; display: grid; gap: 5px; }
.task-row strong { font-size: 15px; overflow-wrap: anywhere; }
.task-row div span { color: var(--muted); font-size: 12px; }
.task-badge { flex: 0 0 auto; padding: 6px 9px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-size: 11px; font-weight: 700; }
.task-badge.is-approval { background: color-mix(in srgb, #d98b2b 15%, transparent); color: #a9610d; }
.calendar-list { display: grid; gap: 8px; }
.calendar-event { display: grid; grid-template-columns: minmax(150px, auto) minmax(0, 1fr); gap: 5px 18px; align-items: baseline; padding: 14px 15px; border: 1px solid var(--line); border-radius: 15px; background: var(--panel-solid); }
.calendar-event time { grid-row: 1 / span 2; color: var(--muted); font-size: 12px; font-weight: 620; }
.calendar-event strong { font-size: 15px; overflow-wrap: anywhere; }
.calendar-event span { color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.connection-dialog { width: min(520px, calc(100% - 32px)); padding: 0; border: 0; border-radius: var(--radius-window); background: transparent; color: var(--ink); }
.connection-dialog::backdrop { background: rgba(6,8,12,.54); backdrop-filter: blur(10px); }
.connection-dialog-panel { display: grid; gap: 18px; padding: 30px; border: 1px solid var(--line); border-radius: var(--radius-window); background: var(--panel-solid); box-shadow: var(--shadow); }
.connection-dialog-panel h2 { margin: 6px 0; font-size: 28px; }
.connection-dialog-panel p { margin: 0; color: var(--muted); line-height: 1.5; }
.connection-dialog-panel a { color: var(--accent); font-size: 13px; font-weight: 650; }
.device-code { padding: 14px 16px; border-radius: 14px; background: var(--panel-soft); font-size: 16px; letter-spacing: .04em; }
.connection-status { min-height: 20px; }
.dashboard.is-editing .tile { border-color: color-mix(in srgb, var(--accent) 55%, var(--line)); cursor: grab; }
.dashboard.is-editing .tile-size { display: grid; }
.tile.is-dragging { opacity: .45; transform: scale(.985); }

.tile-assistant { min-height: 230px; }
.assistant-body { flex: 1; display: flex; align-items: center; gap: var(--space-3); padding: var(--space-3) var(--space-4); }
.assistant-body p { margin: 5px 0 0; color: var(--muted); font-size: 13px; }
.orb { width: 66px; aspect-ratio: 1; display: grid; place-items: center; flex: 0 0 auto; border-radius: 50%; color: white; background: radial-gradient(circle at 34% 25%, #6ee7ff 0, #1680ff 24%, #103796 58%, #071431 100%); box-shadow: inset 0 0 26px rgba(255,255,255,.32), 0 12px 26px rgba(16,82,190,.24); }
.orb span { font-size: 13px; font-weight: 750; letter-spacing: .08em; }
.composer { display: grid; grid-template-columns: 1fr 42px; gap: var(--space-1); padding: var(--space-2); border-top: 1px solid var(--line); }
.composer input { height: 44px; background: var(--bg); }
.send { width: 42px; height: 42px; border: 0; border-radius: 50%; background: var(--ink); color: var(--bg); font-size: 22px; }

.tile-display { min-height: var(--display-height, 520px); grid-column: span 8; position: relative; }
.result { min-height: 0; flex: 1; overflow: auto; padding: 18px 20px 24px; }
.result-empty { height: 100%; min-height: 340px; display: grid; place-content: center; justify-items: center; gap: 12px; color: var(--muted); text-align: center; }
.result-empty span { font-size: 42px; font-weight: 200; }
.result-empty p { margin: 0; }
.result-text { white-space: pre-wrap; line-height: 1.62; font-size: 15px; }
.result-loading { height: 100%; display: grid; place-items: center; color: var(--muted); }
.resize-bar { position: absolute; left: 24px; right: 24px; bottom: 3px; height: 8px; cursor: ns-resize; }
.resize-bar::after { content: ""; display: block; width: 42px; height: 3px; margin: 2px auto; border-radius: 3px; background: var(--line); }
.tile-display.is-fullscreen { position: fixed; inset: 18px; z-index: 100; min-height: 0 !important; grid-column: auto; border-radius: var(--radius-window); }
body.has-fullscreen { overflow: hidden; }
body.has-fullscreen::after { content: ""; position: fixed; inset: 0; z-index: 90; background: rgba(0,0,0,.55); backdrop-filter: blur(8px); }

.mail-summary { flex: 1; display: flex; flex-direction: column; align-items: flex-start; justify-content: center; gap: 5px; padding: 25px; border: 0; background: transparent; text-align: left; }
.mail-accounts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); border-top: 1px solid var(--line); }
.mail-accounts .mail-summary + .mail-summary { border-left: 1px solid var(--line); }
.mail-summary strong { font-size: 20px; letter-spacing: -.025em; }
.mail-summary span { color: var(--muted); font-size: 13px; }
.mail-list { display: grid; }
.mail-row { width: 100%; display: grid; grid-template-columns: minmax(150px, .8fr) minmax(260px, 1.5fr) auto; align-items: center; gap: 22px; min-height: 72px; padding: 13px 12px; border: 0; border-bottom: 1px solid var(--line); background: transparent; text-align: left; }
.mail-row:hover { background: var(--accent-soft); border-radius: 14px; }
.mail-sender, .mail-subject { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mail-sender { font-weight: 650; }
.mail-subject { color: var(--muted); }
.mail-date { color: var(--muted); font-size: 12px; white-space: nowrap; }
.message-meta { display: grid; grid-template-columns: auto 1fr; gap: 7px 18px; padding-bottom: 20px; border-bottom: 1px solid var(--line); font-size: 13px; }
.message-meta dt { color: var(--muted); }
.message-meta dd { margin: 0; }
.message-body { white-space: pre-wrap; line-height: 1.65; padding: 24px 2px; font-size: 14px; }
.back-button { margin-bottom: 16px; border: 0; background: transparent; color: var(--accent); font-weight: 650; }
.sync-status { margin: 14px 4px 0; color: var(--muted); text-align: right; font-size: 11px; }

.visually-hidden { position: fixed; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.document-tile-body { min-height: 150px; flex: 1; display: flex; flex-direction: column; align-items: flex-start; gap: var(--space-2); padding: var(--space-4); }
.upload-dropzone { width: 100%; min-height: 78px; display: flex; align-items: center; gap: var(--space-2); padding: var(--space-2); border: 1px dashed color-mix(in srgb, var(--muted) 42%, transparent); border-radius: var(--radius-control); background: color-mix(in srgb, var(--panel-solid) 65%, transparent); text-align: left; transition: border-color .2s, background .2s, transform .2s; }
.upload-dropzone:hover, .upload-dropzone.is-dragover { border-color: var(--accent); background: var(--accent-soft); }
.upload-dropzone.is-dragover { transform: scale(.995); }
.upload-dropzone:disabled { cursor: wait; opacity: .65; }
.upload-mark { width: 38px; height: 38px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 12px; background: var(--accent-soft); color: var(--accent); font-size: 20px; }
.upload-dropzone span:last-child { min-width: 0; display: grid; gap: 4px; }
.upload-dropzone strong { font-size: 13px; }
.upload-dropzone small, .upload-status { color: var(--muted); font-size: 11px; line-height: 1.35; }
.upload-status { min-height: 15px; margin: 0; overflow-wrap: anywhere; }
.document-list { display: grid; gap: var(--space-2); }
.document-row { width: 100%; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--space-2); align-items: center; padding: 14px var(--space-3); border: 1px solid var(--line); border-radius: var(--radius-control); background: var(--panel-solid); text-align: left; }
.document-row:hover { border-color: color-mix(in srgb, var(--accent) 55%, var(--line)); background: var(--accent-soft); }
.document-row div { min-width: 0; display: grid; gap: 5px; }
.document-row strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.document-row span, .document-row time { color: var(--muted); font-size: 11px; }
.document-row time { white-space: nowrap; }

@media (max-width: 1050px) {
  .tile, .tile[data-size="small"], .tile[data-size="medium"] { grid-column: span 6; }
  .tile[data-size="large"], .tile[data-size="wide"], .tile-display { grid-column: span 12; }
  .topbar { padding: 0 20px; }
  .connection { display: none; }
}
@media (max-width: 720px) {
  .mail-accounts { grid-template-columns: 1fr; }
  .mail-accounts .mail-summary + .mail-summary { border-left: 0; border-top: 1px solid var(--line); }
  .main { padding: 24px 14px 40px; }
  .tile, .tile[data-size] { grid-column: span 12; }
  .quiet { padding: 0 8px; }
  .brand span { display: none; }
  #editButton { padding: 0 4px; font-size: 10px; }
  .mail-row { grid-template-columns: 1fr auto; gap: 5px 12px; }
  .mail-subject { grid-column: 1 / -1; grid-row: 2; }
  .calendar-event { grid-template-columns: 1fr; }
  .calendar-event time { grid-row: auto; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; } }
