/* v1.6.32+ visual refresh: accent color, calmer Chronik, mobile bottom navigation.
   Loaded last; ID-scoped selectors win over the styles that app.js injects at runtime. */

/* ---------- Accent tokens ---------- */
:root{
  --accent:#2f4b7c; --accent-hover:#263e68; --on-accent:#fff;
  --accent-soft:rgba(47,75,124,.10); --accent-line:rgba(47,75,124,.32);
}
:root[data-accent="sage"]{
  --accent:#3d6a54; --accent-hover:#325846; --on-accent:#fff;
  --accent-soft:rgba(61,106,84,.11); --accent-line:rgba(61,106,84,.34);
}
:root[data-accent="clay"]{
  --accent:#974a24; --accent-hover:#873c14; --on-accent:#fff;
  --accent-soft:rgba(151,74,36,.10); --accent-line:rgba(151,74,36,.32);
}
:root[data-accent="petrol"]{
  --accent:#1f6470; --accent-hover:#185560; --on-accent:#fff;
  --accent-soft:rgba(31,100,112,.10); --accent-line:rgba(31,100,112,.32);
}
:root[data-accent="ochre"]{
  --accent:#825618; --accent-hover:#734701; --on-accent:#fff;
  --accent-soft:rgba(130,86,24,.10); --accent-line:rgba(130,86,24,.32);
}
:root[data-accent="berry"]{
  --accent:#913751; --accent-hover:#812744; --on-accent:#fff;
  --accent-soft:rgba(145,55,81,.10); --accent-line:rgba(145,55,81,.32);
}
:root[data-accent="plum"]{
  --accent:#6b3f6e; --accent-hover:#5a345d; --on-accent:#fff;
  --accent-soft:rgba(107,63,110,.10); --accent-line:rgba(107,63,110,.32);
}
:root[data-accent="slate"]{
  --accent:#4a5563; --accent-hover:#3d4652; --on-accent:#fff;
  --accent-soft:rgba(74,85,99,.10); --accent-line:rgba(74,85,99,.32);
}
:root[data-theme="dark"]{
  --accent:#a9bfe8; --accent-hover:#c0d1f0; --on-accent:#111722;
  --accent-soft:rgba(169,191,232,.13); --accent-line:rgba(169,191,232,.34);
}
:root[data-theme="dark"][data-accent="sage"]{
  --accent:#a3cbb5; --accent-hover:#bad9c8; --on-accent:#0f1a14;
  --accent-soft:rgba(163,203,181,.13); --accent-line:rgba(163,203,181,.34);
}
:root[data-theme="dark"][data-accent="clay"]{
  --accent:#e8a585; --accent-hover:#f0bca2; --on-accent:#23130b;
  --accent-soft:rgba(232,165,133,.13); --accent-line:rgba(232,165,133,.34);
}
:root[data-theme="dark"][data-accent="petrol"]{
  --accent:#8fcbd3; --accent-hover:#a8d8de; --on-accent:#0d1c1f;
  --accent-soft:rgba(143,203,211,.13); --accent-line:rgba(143,203,211,.34);
}
:root[data-theme="dark"][data-accent="ochre"]{
  --accent:#e2c071; --accent-hover:#ebcf8f; --on-accent:#231a07;
  --accent-soft:rgba(226,192,113,.13); --accent-line:rgba(226,192,113,.34);
}
:root[data-theme="dark"][data-accent="berry"]{
  --accent:#eda0b8; --accent-hover:#f3b8ca; --on-accent:#2a0e17;
  --accent-soft:rgba(237,160,184,.13); --accent-line:rgba(237,160,184,.34);
}
:root[data-theme="dark"][data-accent="plum"]{
  --accent:#d1a8d3; --accent-hover:#ddbddf; --on-accent:#1f1220;
  --accent-soft:rgba(209,168,211,.13); --accent-line:rgba(209,168,211,.34);
}
:root[data-theme="dark"][data-accent="slate"]{
  --accent:#b7c1cf; --accent-hover:#c9d1dc; --on-accent:#151a20;
  --accent-soft:rgba(183,193,207,.13); --accent-line:rgba(183,193,207,.34);
}
/* Neutral keeps the original monochrome look. */
:root[data-accent="neutral"]{
  --accent:var(--strong); --accent-hover:var(--strong); --on-accent:var(--on-strong);
  --accent-soft:var(--soft); --accent-line:var(--line);
}

/* ---------- Accent usage ---------- */
/* No ::selection colouring: it is evaluated for every element and slowed startup. */
textarea,input,[contenteditable="true"]{caret-color:var(--accent)}

#appShell .topActions .iconButton.active,
#appShell .diarySidebar .topActions .iconButton.active{
  background:var(--accent)!important;
  border-color:var(--accent)!important;
  color:var(--on-accent)!important;
}
/* The red due badge needs a ring in the on-accent colour, or it merges with warm accents. */
#appShell .iconButton.active .tasksDueBadge{border-color:var(--on-accent)}
#appShell .brandControls .headerSettingsButton.active{background:var(--accent)!important;border-color:var(--accent)!important;color:var(--on-accent)!important}

#appShell .quickSave:not(:disabled),
body .primaryButton:not(:disabled):not(.dangerButton){
  background:var(--accent)!important;
  border-color:var(--accent)!important;
  color:var(--on-accent)!important;
}
@media (hover:hover) and (pointer:fine){
  #appShell .quickSave:not(:disabled):hover,
  body .primaryButton:not(:disabled):not(.dangerButton):hover{
    background:var(--accent-hover)!important;
    border-color:var(--accent-hover)!important;
  }
}

#appShell .diaryCalendarDay.selected{background:var(--accent);color:var(--on-accent)}
#appShell .diaryCalendarDay.today:not(.selected){outline-color:var(--accent);color:var(--accent)}
#appShell .diaryTodayBadge{background:var(--accent);color:var(--on-accent)}
#appShell .settingsTabs .settingsAccordionTrigger.active .settingsAccordionIcon{color:var(--accent)}
#appShell .workspaceToggle.private{border-color:var(--accent-line)}

#appShell :is(button,a,summary,[role="button"],input,select):focus-visible{
  outline:2px solid var(--accent)!important;
  outline-offset:2px;
}
#appShell :is(textarea,input[type="text"],input[type="search"],input:not([type])):focus-visible{
  outline:none!important;
  border-color:var(--accent-line)!important;
  box-shadow:0 0 0 3px var(--accent-soft)!important;
}
/* Search box: the ring belongs to the whole box, not to the borderless field inside. */
#appShell .searchBox input:focus-visible{border-color:transparent!important;box-shadow:none!important}
#appShell .searchBox:focus-within{border-color:var(--accent-line);box-shadow:0 0 0 3px var(--accent-soft)}

/* ---------- Chronik: time rail ---------- */
#appShell .eventTime,
#appShell .diaryCalendarDay,
#appShell .calendarTimelineEvent .eventTime{font-variant-numeric:tabular-nums}
/* One rhythm for every Chronik entry: same padding, same line height, same meta gap.
   The time column is exactly as wide as "00:00", so the time starts at the left edge. */
#appShell.diaryMode{--chronik-head:18px;--rail-half:11px}
#appShell.diaryMode .timeline>.event{
  border-bottom-color:transparent;
  grid-template-columns:max-content minmax(0,1fr) auto!important;
  column-gap:22px!important;
  padding-top:11px!important;
  padding-bottom:11px!important;
}
#appShell.diaryMode .timeline>.event :is(.chronikPreviewLine,.chronikSentence,.chronikPlainSentence,.calendarTimelineTitle){
  font-size:var(--chronik-content-size)!important;
  line-height:var(--chronik-content-line)!important;
}
#appShell.diaryMode .timeline>.event :is(.chronikAccordion,.chronikPlainSentence,.calendarTimelineTitle){margin:2px 0 0!important}
#appShell.diaryMode .timeline>.event .chronikPreviewLine{margin:0!important}

/* Head line: time, dot, type icon and source label share one 18px line, centred. */
#appShell.diaryMode .timeline>.event .eventTime{
  position:relative;
  padding-top:0!important;
  align-items:flex-end!important;
  text-align:right;
}
#appShell.diaryMode .timeline>.event .eventTime>span:first-child{
  display:block;
  height:var(--chronik-head);
  line-height:var(--chronik-head);
  color:var(--text);
  font-weight:600;
  letter-spacing:.01em;
  white-space:nowrap;
}
/* Rows without a time keep the same column width. */
#appShell.diaryMode .timeline>.event .eventTime>span:first-child:empty::before{content:"00:00";visibility:hidden}
#appShell.diaryMode .timeline>.event .eventMeta{
  display:flex;
  align-items:center;
  height:var(--chronik-head);
  line-height:var(--chronik-head);
  margin:0!important;
  padding:0!important;
}
/* Written type label ("KALENDER · ASEAG"): tighter spacing around the separator. */
#appShell.diaryMode .timeline>.event .eventMeta{gap:4px!important}
#appShell.diaryMode .timeline>.event .eventActionStack{margin-top:0!important;padding-top:0!important;margin-right:-3px}
/* The menu glyph sits 3px inside its padding; pull it out so it mirrors the time on the left. */

/* Time is right-aligned in its column, so the rail sits exactly in the middle of the gap. */
#appShell.diaryMode .timeline>.event .eventTime::before{
  content:"";
  position:absolute;
  right:calc(-1 * var(--rail-half) - .5px);
  top:-12px;
  bottom:-12px;
  width:1px;
  background:var(--line);
  pointer-events:none;
}
#appShell.diaryMode .timeline>.event:first-child .eventTime::before{top:calc(var(--chronik-head) / 2)}
#appShell.diaryMode .timeline>.event:last-child .eventTime::before{bottom:auto;height:calc(12px + var(--chronik-head) / 2)}
#appShell.diaryMode .timeline>.event:only-child .eventTime::before{display:none}
#appShell.diaryMode .timeline>.event .eventTime::after{
  content:"";
  position:absolute;
  right:calc(-1 * var(--rail-half) - 4px);
  top:calc(var(--chronik-head) / 2 - 4px);
  width:8px;
  height:8px;
  border-radius:50%;
  background:var(--accent);
  box-shadow:0 0 0 3px var(--bg);
  pointer-events:none;
}
#appShell.diaryMode .eventMeta{color:var(--muted)}

/* No colour/scale transitions on navigation controls: the active highlight must switch
   in the same frame as the view, otherwise it visibly trails behind the content. */

#appShell .settingsStartupTimings{font-size:12px;line-height:1.5;color:var(--muted);margin:6px 0 0}

/* ---------- Settings: Darstellung ---------- */
.settingsAppearanceSection{display:grid;gap:18px;padding:14px 4px 6px}
.settingsAppearanceSection .appearanceLabel{font-size:12px;font-weight:700;color:var(--muted);margin-bottom:8px}
#appShell .appearanceSegmented{display:inline-grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:4px;padding:4px;border:1px solid var(--line);border-radius:var(--radius-control);background:var(--surface);width:min(360px,100%);box-sizing:border-box}
#appShell .appearanceSegmented button{min-height:36px!important;height:auto!important;width:auto!important;margin:0!important;padding:0 8px!important;border:0!important;border-radius:9px!important;background:transparent!important;color:var(--text)!important;box-shadow:none!important;font:inherit;font-size:14px;font-weight:600;cursor:pointer}
#appShell .appearanceSegmented button.active{background:var(--accent)!important;color:var(--on-accent)!important}
#appShell .appearanceSwatches{display:grid;grid-template-columns:repeat(auto-fill,minmax(78px,1fr));gap:8px;width:min(560px,100%)}
#appShell .appearanceSwatches button{display:flex!important;flex-direction:column;align-items:center;justify-content:center;gap:7px;height:auto!important;width:auto!important;min-width:0!important;margin:0!important;padding:12px 4px 10px!important;border:1px solid var(--line)!important;border-radius:var(--radius-control)!important;background:var(--surface)!important;color:var(--text)!important;box-shadow:none!important;font:inherit;font-size:12px;font-weight:600;cursor:pointer}
#appShell .appearanceSwatches button.active{border-color:var(--accent)!important;box-shadow:0 0 0 2px var(--accent-soft)!important}
.appearanceSwatch{width:26px;height:26px;border-radius:50%;box-shadow:inset 0 0 0 1px rgba(0,0,0,.08)}
.appearanceSwatch-ink{background:#2f4b7c}
.appearanceSwatch-sage{background:#3d6a54}
.appearanceSwatch-clay{background:#974a24}
.appearanceSwatch-petrol{background:#1f6470}
.appearanceSwatch-ochre{background:#825618}
.appearanceSwatch-berry{background:#913751}
.appearanceSwatch-plum{background:#6b3f6e}
.appearanceSwatch-slate{background:#4a5563}
.appearanceSwatch-neutral{background:linear-gradient(135deg,#171717 50%,#f4f2ed 50%)}
[data-theme="dark"] .appearanceSwatch-ink{background:#a9bfe8}
[data-theme="dark"] .appearanceSwatch-sage{background:#a3cbb5}
[data-theme="dark"] .appearanceSwatch-clay{background:#e8a585}
[data-theme="dark"] .appearanceSwatch-petrol{background:#8fcbd3}
[data-theme="dark"] .appearanceSwatch-ochre{background:#e2c071}
[data-theme="dark"] .appearanceSwatch-berry{background:#eda0b8}
[data-theme="dark"] .appearanceSwatch-plum{background:#d1a8d3}
[data-theme="dark"] .appearanceSwatch-slate{background:#b7c1cf}
[data-theme="dark"] .appearanceSwatch{box-shadow:inset 0 0 0 1px rgba(255,255,255,.12)}

/* ---------- Mobile: bottom navigation ---------- */
@media (max-width:820px){
  #appShell{--bottom-nav-height:62px}
  #appShell.shell{padding-bottom:calc(var(--bottom-nav-height) + max(6px,env(safe-area-inset-bottom)))!important}

  #appShell .diarySidebar .topActions,
  #appShell .topbar .topActions{
    position:fixed!important;
    left:0;
    right:0;
    bottom:0;
    z-index:9;
    margin:0!important;
    transform:none!important;
    width:auto!important;
    display:grid!important;
    grid-template-columns:repeat(5,minmax(0,1fr))!important;
    gap:4px!important;
    padding:6px max(10px,env(safe-area-inset-left)) max(6px,env(safe-area-inset-bottom)) max(10px,env(safe-area-inset-right));
    /* Solid on purpose: backdrop blur made the Android WebView stutter at startup. */
    background:var(--bg);
    border-top:1px solid var(--line);
  }
  #appShell .topActions .iconButton,
  #appShell .diarySidebar .topActions .iconButton{
    height:48px!important;
    width:100%!important;
    border:0!important;
    border-radius:14px!important;
    background:transparent!important;
    color:var(--muted)!important;
    box-shadow:none!important;
  }
  #appShell .topActions .iconButton.active,
  #appShell .diarySidebar .topActions .iconButton.active{
    background:var(--accent-soft)!important;
    color:var(--accent)!important;
  }
  #appShell .topActions .iconButton svg{width:22px;height:22px}
  #appShell .topActions .tasksDueBadge{right:calc(50% - 20px);top:5px}
  /* Mobile active tabs are only tinted, so the badge keeps its accent ring here. */
  #appShell .topActions .iconButton.active .tasksDueBadge{border-color:var(--accent)}

  /* The nav row moved to the bottom; drop its empty grid row and tighten the header. */
  #appShell .diarySidebar .topbar{grid-template-areas:"brand" "title"!important;row-gap:4px!important}
  #appShell .diarySidebar h1{margin:6px 0 0!important}
  #appShell.shell>:is(#todayView,#searchView,#notesView,#tasksView,#knowledgeView,#textView){margin-top:2px!important}

  /* The settings view owns the theme choice on phones. */
  #appShell .brandControls .themeToggle:not(.headerSettingsButton){display:none}

  /* Keep the keyboard and fullscreen editors free of the bar. */
  /* Plain body classes instead of :has(): :has() re-ran on every DOM change and doubled
     style recalculation while the Chronik rendered during the startup animation. */
  body:is(.typingActive,.quickComposerActive,.editComposerActive) #appShell .topActions{display:none!important}
  body:is(.typingActive,.quickComposerActive,.editComposerActive) #appShell.shell{padding-bottom:max(8px,env(safe-area-inset-bottom))!important}
}

