:root {
  --bg: #f6f7f5;
  --surface: #ffffff;
  --text: #1d2b28;
  --muted: #6b7a76;
  --line: #e3e7e4;
  --accent: #1f8f81;
  --accent-soft: #e3f3f0;
  --warn: #b7791f;
  --warn-soft: #fdf3e1;
  --bad: #b4413a;
  --bad-soft: #fbe9e7;
  --good: #2e7d4f;
  --window: #fbf0c2;
  --radius: 10px;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); min-width: 1100px; }
#shell { display: flex; flex-direction: column; height: 100vh; }
h2, h3, p { margin: 0; }
h2 { font-size: 18px; font-weight: 600; }
h3 { font-size: 15px; font-weight: 600; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.spacer { flex: 1; }

button, input, select, textarea { font: inherit; color: inherit; }
button {
  background: var(--surface); border: 1px solid var(--line); border-radius: 8px;
  padding: 7px 13px; cursor: pointer; white-space: nowrap;
}
button:hover { border-color: #c7cfcb; background: #fafbfa; }
button:disabled { opacity: .5; cursor: default; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primary:hover { background: #197a6e; }
button.ghost { border-color: transparent; background: transparent; color: var(--muted); }
button.ghost:hover { color: var(--text); }
button.danger { color: var(--bad); }
input, select, textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
textarea { resize: vertical; line-height: 1.5; }
label { display: grid; gap: 5px; font-size: 12px; color: var(--muted); }
label.check { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text); }
label.check input { width: auto; }
details summary { cursor: pointer; color: var(--muted); font-size: 13px; padding: 4px 0; }
details[open] summary { margin-bottom: 10px; }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card {
  width: min(340px, 100%); display: grid; gap: 12px; padding: 28px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
}
.login-card .brand { margin-bottom: 8px; }
.stack { display: grid; gap: 12px; }
.actions a.button { display: inline-block; }
a.button { display: block; text-align: center; text-decoration: none; padding: 9px 13px; border-radius: 8px; }
a.button.primary { background: var(--accent); color: #fff; }
a.button.primary:hover { background: #197a6e; }
.error { color: var(--bad); font-size: 13px; min-height: 1em; }

.brand { display: flex; align-items: center; gap: 9px; font-weight: 600; font-size: 15px; }
.logo {
  width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center;
  background: var(--accent); color: #fff; font-weight: 700;
}

/* Section switcher in the top-left corner: Life (this panel) and Projects (AIPlatformProjects), same look in both. */
.sections { display: inline-flex; padding: 3px; gap: 2px; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; }
.sections a {
  display: flex; align-items: center; gap: 8px; padding: 4px 12px 4px 4px; border-radius: 8px;
  color: var(--muted); text-decoration: none; font-weight: 600; font-size: 14px;
}
.sections a { padding-left: 8px; }
.sections .icon { width: 24px; height: 24px; flex: none; filter: grayscale(1); opacity: .55; }
.sections a:hover .icon { opacity: .8; }
.sections a:hover { color: var(--text); }
.sections a.active { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(0, 0, 0, .08); }
.sections a.active .icon { filter: none; opacity: 1; }

/* Top bar */
.topbar {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 28px;
  padding: 10px 24px; background: var(--surface); border-bottom: 1px solid var(--line);
}
nav { display: flex; gap: 4px; }
nav a {
  padding: 7px 12px; border-radius: 8px; color: var(--muted); text-decoration: none; display: flex; align-items: center; gap: 6px;
}
nav a:hover { color: var(--text); background: var(--bg); }
nav a.active { color: var(--text); background: var(--accent-soft); font-weight: 500; }
.count { background: var(--accent); color: #fff; border-radius: 10px; padding: 0 7px; font-size: 11px; line-height: 18px; }
.top-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.pill { display: flex; align-items: center; gap: 7px; border-radius: 20px; }
.pill .dot { width: 8px; height: 8px; border-radius: 50%; background: #39b37a; }
.pill.off .dot { background: #c9a227; }

main { flex: 1; min-height: 0; overflow: auto; padding: 20px 24px 40px; }
main .tab { max-width: 1500px; margin: 0 auto; }
main.flush { padding: 0; overflow: hidden; }
main.flush .tab { max-width: none; }
.section-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.empty { padding: 48px; text-align: center; color: var(--muted); border: 1px dashed var(--line); border-radius: var(--radius); }

.banner {
  margin-bottom: 14px; padding: 10px 14px; border-radius: var(--radius);
  background: var(--warn-soft); color: #7a5313; border: 1px solid #f1dcb3;
}

/* Calendar */
#tab-calendar:not([hidden]) { display: flex; flex-direction: column; height: 100%; }
#tab-calendar .banner { margin: 8px 14px 0; }
.cal-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 8px 14px; background: var(--surface); border-bottom: 1px solid var(--line); }
.segmented { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.segmented button { border: 0; border-radius: 0; border-right: 1px solid var(--line); }
.segmented button:last-child { border-right: 0; }
.segmented button.active { background: var(--accent-soft); color: var(--accent); font-weight: 500; }
.legend { display: flex; gap: 4px; flex-wrap: nowrap; }
.legend button { display: flex; align-items: center; gap: 6px; border-color: transparent; background: transparent; font-size: 12px; color: var(--text); padding: 5px 8px; }
.legend button:hover { background: var(--bg); }
.legend button.off { color: #b4bdb9; text-decoration: line-through; }
.legend button.off .sw { opacity: .25; }
.sw { width: 18px; height: 10px; border-radius: 3px; display: inline-block; }
.sw.ths { background: #2aa898; }
.sw.other { background: #f0a04b; }
.sw.discussing { background: #2aa898; opacity: .55; }
.sw.trip { background: #24292f; }
.sw.draft { border: 1.5px dashed #6b8f88; background: #eef3f2; }
.sw.events { background: #e9dcff; border-left: 3px solid #a06bf5; }
.sw.personal { background: #dff6ff; border-left: 3px solid #2ea8ef; }
.sw.manual-hidden { background: #fff; border: 1.5px dotted #8a9a96; }
.sw.window { background: var(--window); border: 1px solid #ecd98a; }

.cal-body { flex: 1; min-height: 0; display: flex; }
.cal { flex: 1; min-width: 0; min-height: 0; overflow: auto; scrollbar-gutter: stable; user-select: none; background: var(--surface); padding-left: 12px; }
.cal.panning { cursor: grab; }
.crow { display: grid; grid-template-columns: 56px 1fr; border-bottom: 1px solid #edf0ee; }
.weeks .crow.month-start { border-top: 2px solid #cfe3de; }
.clabel { position: sticky; left: 0; z-index: 4; background: #fff; display: flex; flex-direction: column; justify-content: center; padding: 4px 8px 4px 6px; font-size: 13px; }
.weeks .clabel { justify-content: flex-start; padding-top: 6px; }
.clabel span { font-size: 11px; }
.cdays { position: relative; display: grid; grid-template-columns: repeat(var(--cols), 1fr); }
.cc { border-left: 1px solid #f0f2f1; font-size: 10px; color: var(--muted); padding: 2px 3px; text-align: right; }
.weeks .cc { font-size: 11px; padding: 3px 6px; }
.cc.alt { background: #f4f8f7; }
.cc.we { background: #f7f4e8; }
.cc.first { color: var(--text); font-weight: 700; }
.cc.out { background: #fbfbfa; }
.cc.sel { background: rgba(31, 143, 129, .18); }
.chead { position: sticky; top: 0; z-index: 5; background: #fff; border-bottom: 1px solid var(--line); }
.chead .cdays { height: 24px; }
.chead .cc { text-align: left; font-size: 11px; font-weight: 700; color: var(--text); padding: 5px 0 0 4px; cursor: default; }
.chead .cc.we { background: #ffd93b; }
.weeks .chead .cc { font-size: 12px; padding: 4px 0 0 6px; }
.chead .clabel { z-index: 4; }
.cwin { position: absolute; top: 0; bottom: 0; background: var(--window); opacity: .6; pointer-events: none; }
.cpast { position: absolute; top: 0; bottom: 0; background: rgba(255, 255, 255, .5); pointer-events: none; z-index: 2; }
.ctoday { position: absolute; top: 0; bottom: 0; background: rgba(229, 72, 77, .06); box-shadow: inset 0 0 0 1px rgba(229, 72, 77, .35); border-radius: 4px; pointer-events: none; z-index: 3; }
.cnow { position: absolute; left: 0; right: 0; height: 2px; background: #e5484d; }
.cnow::before { content: ''; position: absolute; left: 0; top: -3px; width: 2px; height: 8px; background: #e5484d; }
.cnow span { position: absolute; left: 2px; top: -7px; padding: 0 3px; border-radius: 3px; background: #e5484d; color: #fff; font-size: 9px; font-weight: 700; line-height: 14px; }
.cc.is-today { color: #e5484d; font-weight: 700; }
.cbar {
  position: absolute; height: 20px; line-height: 20px; padding: 0 6px; border-radius: 5px; color: #fff; font-size: 12px; font-weight: 500;
  white-space: nowrap; overflow: hidden; z-index: 1; box-shadow: 0 1px 2px rgba(0, 0, 0, .12);
}
.cbar-text { display: block; overflow: hidden; -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 12px), transparent); mask-image: linear-gradient(to right, #000 calc(100% - 12px), transparent); }
.cbar.events, .cbar.personal { font-size: 9.6px; padding-right: 2px; }
.cbar.timed { padding: 1px 2px 0 4px; line-height: 11px; border-radius: 4px; box-shadow: 0 0 0 1px #fff; }
.cbar.timed .cbar-text { height: 100%; white-space: normal; overflow-wrap: anywhere; -webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - 3px), transparent); mask-image: linear-gradient(to bottom, #000 calc(100% - 3px), transparent); }
.cdrop { position: absolute; z-index: 6; border: 1.5px solid #2ea8ef; border-radius: 5px; background: rgba(46, 168, 239, .08); pointer-events: none; }
.cdrop span { position: absolute; left: 50%; transform: translateX(-50%); padding: 0 3px; border-radius: 3px; background: #2ea8ef; color: #fff; font-size: 9px; font-weight: 700; line-height: 12px; white-space: nowrap; }
.cdrop .from { top: -13px; }
.cdrop .until { bottom: -13px; }
.grip { position: absolute; top: 0; bottom: 0; width: 7px; cursor: ew-resize; }
.grip.l { left: 0; }
.grip.r { right: 0; }
.drag-badge { position: fixed; z-index: 40; padding: 3px 8px; border-radius: 6px; background: #1d2b28; color: #fff; font-size: 12px; pointer-events: none; white-space: nowrap; }
.cbar.discussing { opacity: .55; }
.cbar.draft { background: #eef3f2; color: #35564f; border: 1.5px dashed #6b8f88; line-height: 17px; box-shadow: none; }
.cbar.events { background: #e9dcff; color: #5a2bb0; border-left: 3px solid #a06bf5; box-shadow: none; }
.cbar.personal { background: #dff6ff; color: #0b6bc2; border-left: 3px solid #2ea8ef; box-shadow: none; }
.cbar.is-hidden { opacity: .5; outline: 1px dotted #8a9a96; outline-offset: -1px; }
.cbar.cont-l { border-top-left-radius: 0; border-bottom-left-radius: 0; }
.cbar.cont-r { border-top-right-radius: 0; border-bottom-right-radius: 0; }

/* Event panel and tooltip */
.side { flex: none; width: 380px; background: var(--surface); border-left: 1px solid var(--line); padding: 14px 18px 24px; overflow-y: auto; }
.side-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.side form { display: grid; gap: 14px; }
.when { display: flex; gap: 8px; }
.when input[type=time] { width: 120px; flex: none; }
.facts { display: grid; gap: 6px; border-top: 1px solid var(--line); padding-top: 12px; }
.fact { display: grid; grid-template-columns: 84px 1fr; gap: 8px; font-size: 12px; overflow-wrap: anywhere; }
.fact > span:last-child { display: grid; gap: 2px; }
.tip { position: fixed; z-index: 30; width: 340px; max-height: 86vh; overflow-y: auto; padding: 12px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 10px 30px rgba(20, 40, 36, .18); font-size: 13px; }
.tip[hidden] { display: none; }
.tip-note { white-space: pre-wrap; color: var(--muted); font-size: 12px; line-height: 1.45; overflow-wrap: anywhere; }
.event-editor { display: grid; gap: 8px; }
.event-editor input, .event-editor textarea { font-size: 13px; padding: 6px 8px; }
.event-editor input[type=checkbox] { padding: 0; }
.event-editor .ed-title { font-size: 15px; font-weight: 600; }
.event-editor .check { font-size: 12px; }
.ed-checks { display: grid; gap: 4px; }
.ed-place:empty { display: none; }
.ed-place { font-size: 12px; margin-top: -4px; }
.event-editor .modal-actions { margin-top: 0; font-size: 12px; }
.event-editor .danger { padding: 4px 10px; font-size: 12px; }
.event-editor select { font-size: 13px; padding: 6px 8px; }
.ed-repeat-note { font-size: 11px; margin-top: -4px; }
.repeat-row { display: flex; align-items: center; gap: 10px; }
.repeat-row input { width: 70px; }
.repeat-row select { width: 120px; }
.repeat-days { display: flex; gap: 4px; }
.repeat-days button { width: 34px; height: 34px; padding: 0; border-radius: 50%; font-size: 12px; }
.repeat-days button.active { background: #7fb6ec; border-color: #7fb6ec; color: #fff; font-weight: 600; }
.repeat-ends { display: grid; gap: 10px; }
.repeat-ends input[type=date] { width: 150px; }
.repeat-ends input[type=number] { width: 70px; }
.tip-type { justify-self: start; margin-top: 2px; }
.tip-type button { font-size: 12px; padding: 5px 10px; }

/* Offers */
.offers { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 14px; }
.offer { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; display: flex; flex-direction: column; }
.offer img { width: 100%; height: 170px; object-fit: cover; display: block; }
.offer-body { padding: 14px; display: grid; gap: 10px; }
.offer-top { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.draft-text { white-space: pre-wrap; background: var(--bg); border-radius: 8px; padding: 10px; font-size: 13px; line-height: 1.5; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font-size: 12px; background: var(--bg); border: 1px solid var(--line); border-radius: 14px; padding: 3px 9px; color: var(--muted); }
button.chip { color: var(--text); }

.badge { font-size: 11px; padding: 2px 8px; border-radius: 10px; background: var(--bg); color: var(--muted); white-space: nowrap; }
.badge.good { background: #e4f4ea; color: var(--good); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }

/* Search windows */
.rows { display: grid; gap: 8px; }
.row {
  display: grid; grid-template-columns: 1fr auto auto; gap: 18px; align-items: center;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px;
}
.row.off { opacity: .6; }
.row-main { display: grid; gap: 3px; }
.row-meta { display: grid; gap: 3px; justify-items: end; }

/* Settings */
.settings { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; align-items: start; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 18px; display: grid; gap: 12px; }
.panel.wide { grid-column: 1 / -1; }
.panel > button { justify-self: start; }
.status-line { color: var(--muted); }
.status-line.good { color: var(--good); }
.status-line.bad { color: var(--bad); }

/* Dialogs */
.modal { border: 0; border-radius: 14px; padding: 0; width: min(480px, calc(100vw - 32px)); box-shadow: 0 20px 60px rgba(20, 40, 36, .2); }
.modal::backdrop { background: rgba(20, 30, 28, .35); }
.modal form { padding: 22px; display: grid; gap: 14px; }
.modal-actions { display: flex; gap: 8px; align-items: center; margin-top: 4px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 10px; }
#window-form details > label { margin-bottom: 10px; }
.chips:empty { display: none; }
.inline { display: flex; gap: 8px; }

.modal.browser { width: min(1320px, calc(100vw - 32px)); max-height: calc(100vh - 32px); }
.browser-head { display: flex; gap: 12px; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.browser-head .muted { font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 60%; }
.browser-controls { display: flex; gap: 6px; padding: 10px 18px; flex-wrap: wrap; }
.browser-controls input { width: 320px; }
.remote-viewport { overflow: auto; max-height: calc(100vh - 160px); padding: 0 18px 18px; }
.remote-viewport img { width: 100%; border: 1px solid var(--line); border-radius: 8px; cursor: crosshair; display: block; }

#toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 100;
  background: #1d2b28; color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 13px; max-width: calc(100vw - 32px);
}
