/* Вёрстка UI: шапка, дерево папок, список записей и форма */

@font-face {
  font-family: "Roboto";
  src: url("fonts/roboto-cyrillic-400.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}

@font-face {
  font-family: "Roboto";
  src: url("fonts/roboto-cyrillic-500.woff2") format("woff2");
  font-weight: 500 700;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}

@font-face {
  font-family: "Roboto";
  src: url("fonts/roboto-latin-400.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
    U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193,
    U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "Roboto";
  src: url("fonts/roboto-latin-500.woff2") format("woff2");
  font-weight: 500 700;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
    U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193,
    U+2212, U+2215, U+FEFF, U+FFFD;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

:root,
[data-theme='light'] {
  color-scheme: light;
  --color-text: #1a1a1a;
  --color-text-muted: #71717a;
  --color-text-tertiary: #52525b;
  --color-bg: #f4f4f5;
  --color-bg-panel: #fff;
  --color-bg-content: #fafafa;
  --color-bg-group: #e5e5e5;
  --color-border: #e4e4e7;
  --color-border-input: #d4d4d8;
  --color-selected: #e4e4e7;
  --color-link: #2563eb;
  --color-success: #166534;
  --color-error: #b91c1c;
  --color-accent-positive: #16a34a;
  --color-msg-user: #e0e7ff;
  --color-group-rule: #18181b;
  --color-danger-border: #fecaca;
  --color-btn-primary: #2563eb;
  --color-btn-danger: #dc2626;
  --color-btn-success: #166534;
  --shadow-editor: 0 0.75rem 1.5rem rgb(0 0 0 / 0.12);
  --shadow-tab-bar: 0 0.25rem 1.25rem rgb(0 0 0 / 0.14);
  --color-dialog-backdrop: rgb(0 0 0 / 0.5);
}

[data-theme='dark'] {
  color-scheme: dark;
  --color-text: #f4f4f5;
  --color-text-muted: #a1a1aa;
  --color-text-tertiary: #d4d4d8;
  --color-bg: #18181b;
  --color-bg-panel: #27272a;
  --color-bg-content: #27272a;
  --color-bg-group: #18181b;
  --color-border: #3f3f46;
  --color-border-input: #52525b;
  --color-selected: #3f3f46;
  --color-link: #93c5fd;
  --color-success: #4ade80;
  --color-error: #f87171;
  --color-accent-positive: #22c55e;
  --color-msg-user: #312e81;
  --color-group-rule: #71717a;
  --color-danger-border: #7f1d1d;
  --color-btn-primary: #3b82f6;
  --color-btn-danger: #ef4444;
  --color-btn-success: #15803d;
  --shadow-editor: 0 0.75rem 1.5rem rgb(0 0 0 / 0.35);
  --shadow-tab-bar: 0 0.25rem 1.25rem rgb(0 0 0 / 0.35);
  --color-dialog-backdrop: rgb(0 0 0 / 0.65);
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
}

body {
  display: flex;
  flex-direction: column;
  font-family: "Roboto", sans-serif;
  color: var(--color-text);
  background: var(--color-bg);
  --tab-bar-offset: max(0.75rem, env(safe-area-inset-bottom, 0px));
  /* Высота наложения Tab bar; scroll-padding, не отступ в потоке layout */
  --tab-bar-scroll-padding: calc(3.75rem + var(--tab-bar-offset));
}

button,
input,
select,
textarea {
  font-family: inherit;
}

.zone-top {
  position: sticky;
  top: 0;
  z-index: 20;
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 0.5rem 0.75rem;
  background: var(--color-bg-panel);
}

/* PWA window-controls-overlay: шапка — зона перетаскивания окна, кнопки кликабельны */
@media (display-mode: window-controls-overlay) {
  .zone-top {
    padding-top: max(0.5rem, env(titlebar-area-y, 0px));
    padding-left: max(0.75rem, env(titlebar-area-x, 0px));
    padding-right: max(
      0.75rem,
      calc(100vw - env(titlebar-area-x, 0px) - env(titlebar-area-width, 100vw))
    );
    min-height: env(titlebar-area-height, 2.75rem);
    -webkit-app-region: drag;
    app-region: drag;
  }

  .zone-top button {
    -webkit-app-region: no-drag;
    app-region: no-drag;
  }
}

.top-start {
  justify-self: start;
}

.top-end {
  justify-self: end;
}

.zone-top h1 {
  margin: 0;
  justify-self: center;
  font-size: 1.125rem;
  font-weight: 600;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
}

.zone-top .icon-btn {
  border: none;
  background: transparent;
}

.zone-top .icon-btn:hover {
  background: var(--color-bg);
}

.icon-hamburger {
  display: block;
  width: 1.125rem;
  height: 2px;
  background: currentColor;
  box-shadow: 0 -5px 0 currentColor, 0 5px 0 currentColor;
}

.icon-panel {
  display: block;
  width: 1.125rem;
  height: 0.875rem;
  border: 2px solid currentColor;
  border-radius: 2px;
  background: linear-gradient(to left, currentColor 0.35rem, transparent 0.35rem);
}

.app-layout {
  flex: 1 1 auto;
  display: flex;
  min-height: 0;
  overflow: hidden;
  position: relative;
}

/* Свободная панель: не в потоке layout, поверх Menu / Actions / Context */
.panel-free,
#tab-bar.zone-tabs {
  position: fixed;
  left: 50%;
  bottom: var(--tab-bar-offset);
  z-index: 40;
  transform: translateX(-50%);
  pointer-events: auto;
}

.zone-tabs {
  display: flex;
  width: max-content;
  gap: 0.375rem;
  padding: 0.375rem;
  background: var(--color-bg-panel);
  border: none;
  border-radius: 1rem;
  box-shadow: var(--shadow-tab-bar);
}

.zone-tabs button {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.75rem;
  height: 2.75rem;
  padding: 0;
  border: none;
  border-radius: 0.75rem;
  background: transparent;
  color: var(--color-text-muted);
}

.zone-tabs button:hover {
  background: var(--color-bg);
}

.zone-tabs button.selected {
  color: var(--color-text);
  background: var(--color-selected);
}

.tab-icon {
  display: block;
  width: 1.5rem;
  height: 1.5rem;
}

.zone-menu {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  flex: 0 0 14rem;
  width: 14rem;
  max-width: 14rem;
  background: var(--color-bg);
}

.menu-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  scroll-padding-bottom: var(--tab-bar-scroll-padding);
}

.menu-collapsed .zone-menu {
  display: none;
}

.zone-actions {
  position: relative;
  z-index: 1;
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: var(--color-bg);
}

.menu-footer {
  flex: 0 0 auto;
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 0.75rem;
  background: transparent;
}

#user-bar {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
  font-size: 0.875rem;
}

#user-login {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.status {
  margin: 0;
  font-size: 0.875rem;
}

.status.error {
  color: var(--color-error);
}

.status.ok {
  color: var(--color-success);
}

.view-nav.block--group {
  margin: 12px;
  flex: 0 0 auto;
  min-height: auto;
  overflow: visible;
  background: transparent;
}

.nav-icon-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.nav-icon {
  flex: 0 0 auto;
  display: block;
  width: 1.125rem;
  height: 1.125rem;
}

.nav-item-label {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.view-nav .nav-badge {
  margin-left: auto;
}

.view-nav.block--group button.block--subgroup-horizontal {
  border: none;
  border-radius: 0;
  font: inherit;
  cursor: pointer;
  background: transparent;
  color: color-mix(in srgb, var(--color-text) 30%, transparent);
}

.view-nav button.block--subgroup-horizontal {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 0.625rem;
  flex: 0 0 auto;
  width: 100%;
  overflow: hidden;
  text-align: left;
}

.view-nav button.block--subgroup-horizontal:hover {
  background: transparent;
  color: var(--color-text);
}

.view-nav button.block--subgroup-horizontal.selected {
  background: transparent;
  color: var(--color-text);
  font-weight: 600;
}

.nav-badge {
  flex: 0 0 auto;
  min-width: 1.25rem;
  padding: 0.1rem 0.35rem;
  border-radius: 999px;
  background: var(--color-accent-positive);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.25;
  text-align: center;
}

#tab-messages {
  position: relative;
}

.tab-badge {
  position: absolute;
  top: 0.2rem;
  right: 0.2rem;
  min-width: 1rem;
  padding: 0 0.22rem;
  font-size: 0.625rem;
  line-height: 1.15;
}

/* --- Блоки (docs/ui_style.md) --- */

.block {
  background: var(--color-bg-panel);
}

.block--group {
  display: flex;
  flex-direction: column;
  gap: 0;
  margin: 12px;
  padding: 0;
  border-radius: 6px;
  background: var(--color-bg-group);
  overflow: hidden;
}

.page-shell.block--group {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  margin: 12px;
  overflow-x: hidden;
  overflow-y: auto;
  scroll-padding-bottom: var(--tab-bar-scroll-padding);
}

body.object-editor-open .page-shell.block--group {
  overflow: hidden;
}

.page-shell.block--group > .pane-head,
.page-shell.block--group > .pane-head.block--subgroup-horizontal {
  flex: 0 0 auto;
}

.page-shell.block--group > .block--group:not(#settings-body) {
  margin: 0;
  flex: 1 1 auto;
  min-height: 0;
}

.page-shell.block--group > #settings-body.block--group {
  flex: 0 0 auto;
  min-height: auto;
}

.page-shell.block--group > #foods-stats-pane.block--group {
  flex: 0 0 auto;
  min-height: auto;
  overflow: visible;
}

.block--subgroup-horizontal {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  padding: 0.6rem 1rem;
  background: var(--color-bg-panel);
}

.block--subgroup-horizontal--top {
  align-items: flex-start;
}

.block--subgroup-horizontal--bottom {
  align-items: flex-end;
}

.block--card {
  padding: 0.75rem;
  border: none;
  border-radius: 0;
  background: var(--color-bg-panel);
}

.block--group > .block:not(.block--group):not(.block--subgroup-horizontal):not(.block--card) {
  padding: 0.75rem 1rem;
}

.block-group__title {
  margin: 0;
  padding: 1rem 1.5rem;
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--color-text);
  background: var(--color-bg-panel);
}

.page__title {
  margin: 0;
  padding: 1rem 1.5rem;
  font-size: 1.4rem;
  font-weight: 600;
  color: var(--color-text);
  background: var(--color-bg-panel);
}

.divider,
.form-grid-divider {
  height: 5px;
  margin: 1rem;
  padding: 0;
  border: 0;
  background: var(--color-bg-panel);
  opacity: 0.5;
}

.pane-head.block--subgroup-horizontal {
  flex: 0 0 auto;
  flex-wrap: wrap;
  justify-content: space-between;
  border-bottom: none;
  padding: 0.6rem 1rem;
}

.pane-head.block--subgroup-horizontal h2 {
  margin: 0;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--color-text);
}

.settings-section.block--group {
  margin: 0 0 12px;
  overflow: visible;
  flex-shrink: 0;
}

.settings-section.block--group:last-child {
  margin-bottom: 0;
}

.foods-stats-block-title.block-group__title {
  font-size: 1rem;
  padding: 0.75rem 1rem;
}

#settings-body.block--group {
  margin: 0;
  flex: 0 0 auto;
  min-height: auto;
  overflow: visible;
}

.settings-section.block--group > .block {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.menu-footer .block--subgroup-horizontal {
  margin: 0 12px 12px;
  border-radius: 6px;
}

.auth-shell.block--group {
  width: min(24rem, 100%);
  margin: 0;
}

.auth-shell .block--card {
  padding: 1.5rem;
  border-radius: 0.5rem;
}

.zone-actions > .status:not([hidden]) {
  flex: 0 0 auto;
  margin: 0.5rem 0.75rem;
}

#view-dashboard-pane:not([hidden]),
#view-agents-pane:not([hidden]),
#view-variables-pane:not([hidden]),
#view-metrics-pane:not([hidden]),
#view-foods-items-pane:not([hidden]),
#view-foods-sets-pane:not([hidden]),
#view-foods-meals-pane:not([hidden]),
#view-foods-stats-pane:not([hidden]),
#view-rules-pane:not([hidden]),
#view-skills-pane:not([hidden]),
#view-templates-pane:not([hidden]),
#view-tasks-pane:not([hidden]),
#view-events-pane:not([hidden]),
#view-actions-pane:not([hidden]),
#view-messages-pane:not([hidden]),
#view-relations-pane:not([hidden]),
#view-requests-pane:not([hidden]),
#view-settings-pane:not([hidden]) {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

#view-variables-pane:not([hidden]),
#view-metrics-pane:not([hidden]),
#view-foods-items-pane:not([hidden]),
#view-foods-sets-pane:not([hidden]),
#view-foods-meals-pane:not([hidden]),
#view-foods-stats-pane:not([hidden]),
#view-rules-pane:not([hidden]),
#view-skills-pane:not([hidden]),
#view-templates-pane:not([hidden]),
#view-tasks-pane:not([hidden]),
#view-events-pane:not([hidden]),
#view-actions-pane:not([hidden]),
#view-messages-pane:not([hidden]),
#view-relations-pane:not([hidden]),
#view-requests-pane:not([hidden]) {
  position: relative;
}

#variables-list-pane,
#foods-items-list-pane,
#foods-sets-list-pane,
#foods-meals-list-pane,
#rules-list-pane,
#skills-list-pane,
#templates-list-pane,
#tasks-list-pane,
#events-list-pane,
#actions-list-pane,
#messages-list-pane,
#relations-list-pane,
#requests-list-pane,
#agent-thread {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

#variables-list-pane,
#foods-items-list-pane,
#foods-sets-list-pane,
#foods-meals-list-pane,
#tasks-list-pane,
#events-list-pane,
#actions-list-pane,
#messages-list-pane,
#templates-list-pane,
#rules-list-pane,
#skills-list-pane,
#relations-list-pane,
#requests-list-pane {
  flex: 1 1 auto;
  min-width: 0;
  overflow-x: hidden;
}

#agent-thread {
  flex: 1 1 auto;
  background: var(--color-bg-content);
}

#tasks-list-pane,
#messages-list-pane {
  flex: 1 1 auto;
}

.pane-head {
  flex: 0 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.75rem;
}

.pane-head h2 {
  margin: 0;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--color-text);
}

.variables-path {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.15rem 0.2rem;
  min-width: 0;
  flex: 1 1 auto;
  font-size: 0.875rem;
  font-weight: 600;
}

.variables-path button {
  border-color: transparent;
  background: transparent;
  padding: 0.15rem 0.3rem;
  color: var(--color-link);
}

.variables-path button:hover {
  background: var(--color-bg);
  text-decoration: underline;
}

.variable-quick-form {
  flex: 0 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.5rem;
  padding: 0.75rem;
  border-bottom: 1px solid var(--color-border);
}

.variable-quick-form[hidden] {
  display: none;
}

.variable-quick-value-wrap {
  flex: 1 1 12rem;
  min-width: 8rem;
}

.variable-quick-form textarea {
  min-height: 2.5rem;
}

.variable-quick-version-label {
  flex: 0 1 16rem;
  min-width: 12rem;
}

.variable-quick-versions {
  flex: 1 1 100%;
  min-width: 0;
  overflow: auto;
}

.variable-item-body {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
  padding: 0.25rem 0;
  text-align: left;
  border-color: transparent;
  background: transparent;
}

.variable-item-name-row {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  width: 100%;
  min-width: 0;
}

.variable-item-name {
  flex: 1 1 auto;
  min-width: 0;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.variable-item-meta {
  flex: 0 0 auto;
  display: flex;
  align-items: baseline;
  gap: 0.25rem;
  color: var(--color-text-muted);
  white-space: nowrap;
}

.variable-item-value {
  font-variant-numeric: tabular-nums;
}

.variable-item-unit {
  flex: 0 0 auto;
}

.variable-item-description {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
  font-size: 0.8125rem;
  color: var(--color-text-muted);
  word-break: break-word;
}

.variable-item-id,
.variable-record-id {
  margin: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.8125rem;
  color: var(--color-text-muted);
  word-break: break-all;
  user-select: all;
}

.variable-record-id {
  margin-bottom: 0.75rem;
}

.pane-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
}

button {
  font: inherit;
  padding: 0.25rem 0.5rem;
  border: 1px solid var(--color-border-input);
  border-radius: 0.25rem;
  background: var(--color-bg-panel);
  color: var(--color-text);
  cursor: pointer;
}

button:hover {
  background: var(--color-bg);
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

button.danger {
  color: var(--color-error);
  border-color: var(--color-danger-border);
}

.form-actions button:not(.danger),
button[id$="-save"],
button[id$="-add"]:not(.danger),
#composer-send,
#task-save,
#event-save,
#action-save,
#message-save,
#relation-save,
#request-save,
#rule-save,
#skill-save,
#template-save,
#variable-save,
#foods-items-save,
#foods-sets-save,
#foods-meals-save,
.metric-set-btn,
#ai-form button[type="submit"],
dialog form button[type="submit"]:not(.danger) {
  background: var(--color-btn-success);
  border-color: transparent;
  color: #fff;
}

.form-actions button:not(.danger):hover,
button[id$="-save"]:hover,
.metric-set-btn:hover,
#composer-send:hover,
dialog form button[type="submit"]:not(.danger):hover {
  filter: brightness(1.05);
}

button.danger,
button[id$="-delete"].danger,
button[id$="-fail"] {
  background: var(--color-btn-danger);
  border-color: transparent;
  color: #fff;
}

button.danger:hover,
button[id$="-delete"].danger:hover {
  filter: brightness(1.05);
}

.dialog-actions button[type="button"][value="cancel"],
button[id$="-close"],
button[id$="-cancel"],
#folder-dialog-cancel,
#variable-dialog-cancel {
  background: var(--color-btn-primary);
  border-color: transparent;
  color: #fff;
}

#agents-threads-list .list-btn.block--subgroup-horizontal {
  border: none;
  border-radius: 0;
  margin: 0;
  justify-content: flex-start;
}

.list-btn {
  display: block;
  width: 100%;
  overflow: hidden;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
  border-color: transparent;
  background: transparent;
  margin: 0.125rem 0;
}

.list-btn:hover {
  background: var(--color-bg);
}

.list-btn.selected {
  background: var(--color-selected);
  font-weight: 600;
}

.list-meta {
  display: block;
  font-weight: 400;
  color: var(--color-text-muted);
  font-size: 0.75rem;
}

#variables-list,
#foods-items-list,
#foods-sets-list,
#foods-meals-list,
#rules-list,
#skills-list,
#templates-list,
#tasks-list,
#events-list,
#actions-list,
#messages-list,
#relations-list,
#requests-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  padding: 0.75rem;
  scroll-padding-bottom: var(--tab-bar-scroll-padding);
}

#agents-threads-list {
  max-height: 16rem;
  overflow: auto;
  padding: 0.25rem 0;
}

.agent-thread-switch-wrap {
  position: relative;
  flex: 0 0 auto;
}

.agent-threads-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 0.25rem);
  z-index: 25;
  min-width: 14rem;
  max-width: min(20rem, 70vw);
  background: var(--color-bg-panel);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-editor);
}

#ai-list,
#api-tokens-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  padding: 0.75rem;
}

#messages {
  flex: 1 1 auto;
  overflow: auto;
  padding: 0.75rem;
  scroll-padding-bottom: var(--tab-bar-scroll-padding);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.bubble {
  max-width: 48rem;
  padding: 0.625rem 0.75rem;
  border-radius: 0.5rem;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.9375rem;
  line-height: 1.4;
}

.bubble.user {
  align-self: flex-end;
  background: var(--color-msg-user);
}

.bubble.assistant {
  align-self: flex-start;
  background: var(--color-bg-panel);
  border: 1px solid var(--color-border);
}

.bubble.tool {
  align-self: flex-start;
  background: var(--color-bg);
  color: var(--color-text-tertiary);
  font-size: 0.8125rem;
  max-width: 100%;
}

.bubble .role {
  display: block;
  font-size: 0.75rem;
  color: var(--color-text-muted);
  margin-bottom: 0.25rem;
}

.tool-calls {
  margin-top: 0.35rem;
  color: var(--color-text-tertiary);
  font-size: 0.8125rem;
}

.agent-status {
  padding: 0 0.75rem 0.25rem;
}

#composer {
  flex: 0 0 auto;
  display: flex;
  gap: 0.5rem;
  padding: 0.75rem;
  background: var(--color-bg-panel);
  border-top: 1px solid var(--color-border);
}

#composer textarea {
  flex: 1 1 auto;
  min-height: 3rem;
  resize: vertical;
}

.composer-templates-wrap {
  position: relative;
  flex: 0 0 auto;
  align-self: flex-end;
}

#composer-templates-menu {
  position: absolute;
  bottom: 100%;
  left: 0;
  z-index: 20;
  min-width: 12rem;
  max-height: 16rem;
  margin-bottom: 0.25rem;
  overflow: auto;
  background: var(--color-bg-panel);
  border: 1px solid var(--color-border);
}

#composer-templates-menu button {
  display: block;
  width: 100%;
  padding: 0.5rem 0.75rem;
  text-align: left;
  border: none;
  border-radius: 0;
  background: transparent;
}

#composer-templates-menu button:hover {
  background: var(--color-selected);
}

#composer-templates-menu p {
  margin: 0;
  padding: 0.5rem 0.75rem;
}

#rule-text,
#skill-text,
#template-text {
  min-height: 16rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.875rem;
}

#request-url {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.875rem;
}

#request-data,
#task-input,
#task-output {
  min-height: 8rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.875rem;
}

#rule-form h3,
#skill-form h3,
#variable-form h3,
#task-form h3,
#relation-form h3,
#request-form h3,
#ai-form h3 {
  margin: 0 0 0.75rem;
  font-size: 1rem;
}

#task-editor:not([hidden]),
#event-editor:not([hidden]),
#action-editor:not([hidden]),
#message-editor:not([hidden]),
#template-editor:not([hidden]),
#variable-editor:not([hidden]),
#foods-items-editor:not([hidden]),
#foods-sets-editor:not([hidden]),
#foods-meals-editor:not([hidden]),
#rule-editor:not([hidden]),
#skill-editor:not([hidden]),
#relation-editor:not([hidden]),
#request-editor:not([hidden]) {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  height: 100%;
  max-height: none;
  overflow: hidden;
  background: var(--color-bg-panel);
  border-bottom: 1px solid var(--color-border);
  box-shadow: var(--shadow-editor);
  animation: task-editor-in 0.2s ease;
}

#action-editor:not([hidden]) {
  z-index: 6;
}

.task-editor-panel > form,
.task-editor-panel > #message-reader:not([hidden]) {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  margin: 0;
  padding: 0;
}

.task-editor-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  padding: 0.75rem;
}

.task-editor-foot {
  flex: 0 0 auto;
  margin: 0;
  padding: 0.75rem;
  border-top: 1px solid var(--color-border);
  background: var(--color-bg-panel);
}

@keyframes task-editor-in {
  from {
    transform: translateY(-100%);
  }
  to {
    transform: translateY(0);
  }
}

.task-editor-head {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem;
  border-bottom: 1px solid var(--color-border);
}

.task-editor-head h3 {
  margin: 0;
  font-size: 1rem;
}

#foods-meals-form .task-editor-scroll {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

#foods-meals-add-food {
  flex: 0 0 auto;
  position: relative;
  align-items: flex-end;
}

#foods-meals-items {
  flex: 1 1 auto;
  min-height: 4rem;
  max-height: none;
  overflow: auto;
  margin-top: 0.5rem;
}

.foods-sets-items {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin: 0.75rem 0;
}

.foods-sets-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 0.875rem;
}

.foods-meals-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
}

.foods-meals-item-name {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.foods-meals-item-amount {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex: 0 0 auto;
}

.foods-meals-item-amount input {
  width: 5rem;
}

#foods-stats-pane.block--group {
  margin: 0;
  display: flex;
  flex-direction: column;
  overflow: visible;
}

#foods-stats-content {
  flex: 0 0 auto;
  min-height: auto;
  overflow: visible;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  padding: 0 12px 12px;
}

#foods-stats-content .block--group {
  overflow: visible;
}

.foods-stats-date-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
}

.foods-stats-date-nav input[type="date"] {
  min-width: 9rem;
}

.foods-stats-block-title {
  margin: 0 0 0.5rem;
  font-size: 0.9375rem;
  font-weight: 500;
}

.foods-stats-grid {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.foods-stats-row {
  position: relative;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--color-border);
  background: var(--color-bg-panel);
  font-size: 0.875rem;
  overflow: hidden;
}

.foods-stats-row-fill {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  background: #2563eb;
  opacity: 0.2;
  pointer-events: none;
  z-index: 0;
}

.foods-stats-row-has-norm::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 0;
  bottom: 0;
  border-left: 1px solid #94a3b8;
  transform: translateX(-50%);
  pointer-events: none;
  z-index: 1;
}

.foods-stats-row-name,
.foods-stats-row-value {
  position: relative;
  z-index: 2;
}

.foods-stats-row-name {
  flex: 1 1 auto;
  min-width: 0;
}

.foods-stats-row-value {
  flex: 0 0 auto;
  text-align: right;
  white-space: nowrap;
}

#metrics-pane.block--group {
  gap: 0.75rem;
  overflow: visible;
}

.metrics-list.block--group {
  gap: 0.75rem;
  overflow: visible;
}

.metric-row.block--group {
  margin: 0;
  position: relative;
  z-index: 0;
  overflow: visible;
}

.metric-row.block--group.metric-row-menu-open {
  z-index: 25;
}

.metric-row .block-group__title.metric-row-title {
  padding: 0.75rem 1rem;
}

.metric-value-row.block--subgroup-horizontal {
  flex-wrap: nowrap;
  align-items: center;
}

.metric-value-field {
  flex: 1 1 auto;
  min-width: 0;
}

.metric-value-field input,
.metric-value-field textarea {
  width: 100%;
  box-sizing: border-box;
}

.metric-more-wrap {
  position: relative;
  flex: 0 0 auto;
}

.metric-more-wrap > .icon-btn {
  border: none;
  background: transparent;
}

.metric-more-wrap > .icon-btn:hover {
  background: var(--color-bg);
}

.metric-more-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 0.15rem);
  z-index: 30;
  display: none;
  flex-direction: column;
  gap: 0.25rem;
  min-width: 11rem;
  padding: 0.35rem;
  background: var(--color-bg-panel);
  border: 1px solid var(--color-border);
  border-radius: 0.25rem;
  box-shadow: 0 0.5rem 1rem rgb(0 0 0 / 0.12);
}

.metric-more-menu:not([hidden]) {
  display: flex;
}

.metric-more-menu button {
  width: 100%;
  padding: 0.5rem 0.75rem;
  text-align: left;
  border: none;
  border-radius: 0.2rem;
  background: transparent;
  color: var(--color-text);
  cursor: pointer;
}

.metric-more-menu button:hover {
  background: var(--color-bg);
}

.metrics-picker-list {
  max-height: min(50vh, 24rem);
  overflow-y: auto;
}

.metric-variable-picker {
  min-width: min(100vw - 2rem, 28rem);
}

.foods-meals-item-unit {
  min-width: 1.5rem;
}

#variable-versions-block {
  flex: 0 1 16rem;
  min-height: 8rem;
  overflow: auto;
  padding: 0.75rem;
  border-top: 1px solid var(--color-border);
}

#variable-versions-block[hidden] {
  display: none;
}

#variable-versions-block h3 {
  margin: 0 0 0.75rem;
  font-size: 1rem;
}

.rules-table,
.skills-table,
.templates-table,
.relations-table,
.requests-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.rules-table th,
.rules-table td,
.skills-table th,
.skills-table td,
.templates-table th,
.templates-table td,
.relations-table th,
.relations-table td,
.requests-table th,
.requests-table td {
  padding: 0.375rem 0.5rem;
  border-bottom: 1px solid var(--color-border);
  text-align: left;
  vertical-align: top;
}

.rules-table button,
.skills-table button,
.templates-table button,
.relations-table button,
.requests-table button {
  width: 100%;
  text-align: left;
  border-color: transparent;
  background: transparent;
}

.task-item {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  width: 100%;
  padding: 0.75rem;
  text-align: left;
  border: none;
  background: var(--color-bg-panel);
  cursor: pointer;
}

.task-item.selected {
  background: var(--color-selected);
}

.task-item-main {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
}

.task-item-heading {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  flex: 1 1 auto;
  min-width: 0;
}

.task-item-name {
  flex: 1 1 auto;
  min-width: 0;
  font-weight: 500;
  word-break: break-word;
}

.task-status-dots {
  display: flex;
  align-items: center;
  gap: 0.2rem;
  flex: 0 0 auto;
  margin-top: 0.4em;
}

.task-status-dot {
  flex: 0 0 auto;
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
}

.task-status-dot-completed {
  background: #2563eb;
}

.task-status-dot-overdue {
  background: #dc2626;
}

.task-status-dot-inactive {
  background: #a1a1aa;
}

.task-status-dot-active {
  background: #16a34a;
}

.task-item-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  font-size: 0.8125rem;
  color: var(--color-text-muted);
}

.task-item-linked-actions {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
  padding-left: 1.25rem;
}

.task-item-linked-action {
  font-size: 0.8125rem;
  color: var(--color-text-muted);
  word-break: break-word;
  cursor: pointer;
}

.task-item-linked-action:hover,
#task-linked-actions-list .task-linked-action-row:hover {
  color: var(--color-text);
}

#task-linked-actions-list .task-linked-action-row {
  cursor: pointer;
}

.task-day-group {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--color-text-tertiary);
  padding: 0.25rem 0.25rem 0;
}

.task-day-group-divider {
  border-top: 3px solid var(--color-group-rule);
  margin-top: 0.25rem;
  padding-top: 0.75rem;
}

#task-relations,
#event-relations,
#action-relations,
#task-linked-actions,
#task-checklists {
  margin: 1rem 0 0;
}

#task-relations h4,
#event-relations h4,
#action-relations h4,
#task-linked-actions h4,
#task-checklists h4 {
  margin: 0 0 0.5rem;
  font-size: 0.875rem;
}

#task-relations-list > .muted,
#event-relations-list > .muted,
#action-relations-list > .muted,
#task-linked-actions-list > .muted {
  margin: 0.25rem 0 0;
}

.task-checklists-list {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.task-checklist-item-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.task-checklist-item-row label {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex: 1 1 auto;
  margin: 0;
}

.task-checklist-item-row input[type="checkbox"] {
  flex: 0 0 auto;
}

.task-checklist-item-row input[type="text"] {
  flex: 1 1 auto;
  min-width: 0;
}

.task-checklist-item-meta {
  flex: 0 0 auto;
  font-size: 0.75rem;
}

.task-checklist-add {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.task-checklist-add label {
  flex: 1 1 12rem;
  margin: 0;
}

#task-relations-list td:last-child,
#event-relations-list td:last-child,
#action-relations-list td:last-child {
  white-space: nowrap;
  width: 1%;
}

.task-item .task-actions {
  position: relative;
  flex: 0 0 auto;
}

.task-item .task-actions-row {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.15rem;
}

.task-item .task-actions .icon-btn {
  width: 2rem;
  height: 2rem;
}

.icon-check {
  display: block;
  width: 0.55rem;
  height: 0.3rem;
  margin-bottom: 0.15rem;
  border-left: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(-45deg);
}

.icon-checklist-open {
  flex: 0 0 auto;
  display: block;
  width: 0.75rem;
  height: 0.75rem;
  border: 1.5px solid currentColor;
  border-radius: 0.125rem;
  opacity: 0.65;
}

.icon-play {
  display: block;
  width: 0;
  height: 0;
  margin-left: 0.1rem;
  border-style: solid;
  border-width: 0.32rem 0 0.32rem 0.5rem;
  border-color: transparent transparent transparent currentColor;
}

.icon-dots {
  display: block;
  width: 0.25rem;
  height: 0.25rem;
  border-radius: 50%;
  background: currentColor;
  box-shadow: -0.4rem 0 0 currentColor, 0.4rem 0 0 currentColor;
}

.icon-repeat {
  display: block;
  width: 0.875rem;
  height: 0.875rem;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  position: relative;
}

.icon-repeat::after {
  content: "";
  position: absolute;
  top: -0.2rem;
  right: -0.05rem;
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 0 0 0.28rem 0.38rem;
  border-color: transparent transparent transparent currentColor;
  transform: rotate(-35deg);
}

.task-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 0.15rem);
  z-index: 6;
  display: none;
  flex-direction: column;
  gap: 0.5rem;
  min-width: 12rem;
  padding: 0.5rem;
  background: var(--color-bg-panel);
  border: 1px solid var(--color-border);
  border-radius: 0.25rem;
  box-shadow: 0 0.5rem 1rem rgb(0 0 0 / 0.12);
}

.task-menu:not([hidden]) {
  display: flex;
}

.task-item .task-actions-row button {
  width: auto;
  text-align: center;
}

.task-menu button {
  width: 100%;
  padding: 0.5rem 0.75rem;
  text-align: left;
}

.rules-table tr.selected,
.skills-table tr.selected,
.templates-table tr.selected,
.relations-table tr.selected,
.requests-table tr.selected {
  background: var(--color-selected);
}

#tasks-list,
#events-list,
#actions-list,
#messages-list,
#templates-list,
#variables-list,
#foods-items-list,
#foods-sets-list,
#foods-meals-list,
#rules-list,
#skills-list,
#relations-list,
#requests-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.message-item {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  width: 100%;
  padding: 0.75rem;
  text-align: left;
  border: none;
  background: var(--color-bg-panel);
}

.message-item.selected {
  background: var(--color-selected);
}

.message-item.unread .message-item-sender {
  font-weight: 600;
}

.message-item-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.5rem 1rem;
  font-size: 0.8125rem;
  cursor: pointer;
}

.message-item-sender {
  flex: 1 1 auto;
  min-width: 0;
}

.message-item-time,
.message-item-status {
  color: var(--color-text-muted);
  flex: 0 0 auto;
}

.message-item-body {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  cursor: pointer;
  font-size: 0.875rem;
}

.message-item-heading {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
}

.message-unread-dot {
  flex: 0 0 auto;
  width: 0.5rem;
  height: 0.5rem;
  margin-top: 0.35em;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: #16a34a;
  cursor: pointer;
}

.message-item-title {
  flex: 1 1 auto;
  min-width: 0;
  font-weight: 500;
}

.message-item-text {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  overflow: hidden;
  white-space: pre-wrap;
  word-break: break-word;
}

#message-reader {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  padding: 0.75rem;
}

#message-reader-sender {
  margin: 0 0 0.5rem;
  font-size: 0.8125rem;
  color: var(--color-text-muted);
}

#message-reader-title {
  margin: 0 0 0.75rem;
  font-size: 1rem;
  font-weight: 500;
}

#message-reader-text {
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.875rem;
}

.muted {
  margin: 0;
  color: var(--color-text-muted);
  font-size: 0.875rem;
}

.variable-item {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  width: 100%;
  box-sizing: border-box;
  padding: 0.5rem 0.75rem;
  text-align: left;
  border: none;
  background: var(--color-bg-panel);
}

.variable-item.selected {
  background: var(--color-selected);
}

.variable-item .task-item-name {
  flex: 1 1 auto;
  min-width: 0;
}

.var-type-icon {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  margin-top: 0.25rem;
  color: var(--color-text-tertiary);
}

.var-icon {
  display: block;
  width: 1.125rem;
  height: 1.125rem;
}

.variable-item .icon-btn {
  flex: 0 0 auto;
  width: 2rem;
  height: 2rem;
  margin-top: 0.125rem;
}

.entries-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.entries-table th,
.entries-table td {
  padding: 0.375rem 0.5rem;
  border-bottom: 1px solid var(--color-border);
  text-align: left;
  vertical-align: top;
}

.entries-table button {
  width: 100%;
  text-align: left;
  border-color: transparent;
  background: transparent;
}

.entries-table tr.selected {
  background: var(--color-selected);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr));
  gap: 0.75rem;
}

.form-grid .full-width {
  grid-column: 1 / -1;
}

.form-grid-divider {
  grid-column: 1 / -1;
  border: none;
  border-top: 1px solid var(--color-border);
  margin: 0.25rem 0;
}

label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.875rem;
  color: var(--color-text);
}

input,
select,
textarea {
  font: inherit;
  padding: 0.375rem 0.5rem;
  border: 1px solid var(--color-border-input);
  border-radius: 0.25rem;
  background: var(--color-bg-panel);
  color: var(--color-text);
}

textarea {
  min-height: 6rem;
  resize: vertical;
}

fieldset.flags {
  margin: 0.75rem 0;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--color-border);
  border-radius: 0.25rem;
}

fieldset.flags label {
  flex-direction: row;
  align-items: center;
  margin: 0.25rem 0;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0.75rem 0;
}

.variable-versions {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8125rem;
}

.variable-versions th,
.variable-versions td {
  padding: 0.375rem 0.5rem;
  border-bottom: 1px solid var(--color-border);
  text-align: left;
  vertical-align: top;
}

.variable-versions td {
  white-space: pre-wrap;
  word-break: break-word;
}

dialog {
  border: 1px solid var(--color-border);
  border-radius: 0.5rem;
  padding: 1rem;
  min-width: 18rem;
}

#action-dialog {
  min-width: 24rem;
}

.datetime-with-now,
.field-with-button {
  display: flex;
  gap: 0.35rem;
  align-items: center;
}

.datetime-with-now input,
.field-with-button input {
  flex: 1 1 auto;
  min-width: 0;
}

.foods-items-extra {
  margin-top: 0.75rem;
}

.foods-items-extra-fields {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.foods-items-extra-row label {
  flex: 1 1 auto;
  min-width: 0;
}

.foods-items-extra-add {
  margin-bottom: 0.75rem;
}

.foods-items-extra-add label {
  flex: 1 1 auto;
  min-width: 0;
}

.foods-items-json-import {
  margin-top: 0.75rem;
}

.foods-items-json-import textarea {
  width: 100%;
  min-height: 6rem;
  margin-top: 0.25rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.8125rem;
  line-height: 1.4;
}

.foods-items-json-import button {
  margin-top: 0.5rem;
}

.foods-items-catalog-search-wrap {
  position: relative;
}

.foods-items-catalog-suggest {
  position: absolute;
  z-index: 20;
  left: 0;
  right: 0;
  top: calc(100% - 0.25rem);
  max-height: 14rem;
  overflow-y: auto;
  border: 1px solid var(--color-border-input);
  border-radius: 0.25rem;
  background: var(--color-bg-panel);
  box-shadow: 0 4px 12px rgb(0 0 0 / 0.08);
}

.foods-items-catalog-empty {
  margin: 0;
  padding: 0.5rem 0.65rem;
  font-size: 0.875rem;
}

.foods-items-catalog-option {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  width: 100%;
  padding: 0.5rem 0.65rem;
  text-align: left;
  border: none;
  border-bottom: 1px solid var(--color-bg);
  background: var(--color-bg-panel);
  cursor: pointer;
  font: inherit;
}

.foods-items-catalog-option:last-child {
  border-bottom: none;
}

.foods-items-catalog-option:hover,
.foods-items-catalog-option:focus-visible {
  background: var(--color-bg);
}

.foods-items-catalog-option-primary {
  font-size: 0.875rem;
}

.foods-items-catalog-option-secondary {
  font-size: 0.75rem;
  color: var(--color-text-muted);
}

.foods-items-catalog-option-id {
  font-size: 0.75rem;
  color: var(--color-text-muted);
}

dialog::backdrop {
  background: var(--color-dialog-backdrop);
}

dialog h3 {
  margin: 0 0 0.75rem;
  font-size: 1rem;
}

dialog label {
  margin-bottom: 0.75rem;
}

#token-dialog-value {
  width: 100%;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.75rem;
  word-break: break-all;
}

label.inline {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

#messages-list-pane > .inline {
  flex: 0 0 auto;
  padding: 0.5rem 0.75rem 0;
}

.action-form-row {
  margin: 0 0 0.5rem;
  align-items: center;
  gap: 0.5rem;
}

.action-form-row .block-group__title {
  flex: 0 0 auto;
  margin: 0;
  min-width: 9.5rem;
}

.action-form-row > input[type="text"],
.action-form-row > input[type="datetime-local"] {
  flex: 1 1 12rem;
  min-width: 0;
}

.action-form-row > input[type="checkbox"] {
  flex: 0 0 auto;
  width: 1rem;
  height: 1rem;
  margin: 0;
}

.action-form-row > button {
  flex: 0 0 auto;
  min-width: 2.5rem;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

.row-check {
  flex-direction: row;
  align-items: center;
}

#settings-ai {
  display: flex;
  padding: 0.75rem;
}

.settings-default {
  margin: 0 0 0.5rem;
}

.settings-default select {
  min-width: 12rem;
  max-width: 100%;
}

.settings-split {
  flex: 1 1 auto;
  display: grid;
  grid-template-columns: minmax(12rem, 16rem) 1fr;
  gap: 1rem;
}

.settings-split > div {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

#ai-form {
  overflow: auto;
}

#settings-language,
#settings-timezone,
#settings-telegram,
#settings-tokens {
  padding: 0.75rem;
  border-top: 1px solid var(--color-border);
}

.token-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin: 0.25rem 0;
}

@media (max-width: 48rem) {
  .zone-menu {
    position: absolute;
    top: 0;
    bottom: 0;
    z-index: 10;
    box-shadow: 0 0 1.5rem rgb(0 0 0 / 0.16);
    left: 0;
  }

  .app-layout {
    position: relative;
  }

  .settings-split {
    grid-template-columns: 1fr;
  }
}

.timeline-date-nav {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.35rem 0.75rem;
  background: var(--color-bg-panel);
  border-bottom: 1px solid var(--color-border-input);
}

.timeline-date-label {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 8rem;
  text-align: center;
}

.timeline-date-value {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--color-text);
}

.timeline-date-hint {
  font-size: 0.75rem;
  font-weight: 400;
  color: var(--color-text-muted);
}

.icon-chevron-left {
  display: block;
  width: 0.45rem;
  height: 0.45rem;
  border-left: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg);
}

.icon-chevron-right {
  display: block;
  width: 0.45rem;
  height: 0.45rem;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(-45deg);
}

#timeline-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  scroll-padding-bottom: var(--tab-bar-scroll-padding);
  background: var(--color-selected);
}

#timeline-block {
  position: relative;
  width: 2880px;
}

#timeline-hours {
  position: sticky;
  top: 0;
  z-index: 3;
  display: flex;
  height: 2rem;
  margin-bottom: 4px;
  background: var(--color-bg-panel);
  border-bottom: 1px solid var(--color-border-input);
}

.timeline-hour {
  box-sizing: border-box;
  flex: 0 0 120px;
  width: 120px;
  padding: 0.35rem 0.4rem;
  font-size: 0.75rem;
  color: var(--color-text-muted);
  border-right: 1px solid var(--color-bg);
}

#timeline-now {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 5px;
  margin-left: -2px;
  background: rgb(0 0 0 / 0.1);
  z-index: 2;
  pointer-events: none;
}

.timeline-group {
  width: 2880px;
  margin-bottom: 2px;
}

.timeline-group-title {
  position: sticky;
  left: 0;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;
  width: var(--timeline-view-width, 100%);
  padding: 0.35rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--color-text-tertiary);
  text-align: center;
}

.timeline-group-create {
  position: absolute;
  right: 0.35rem;
  top: 50%;
  transform: translateY(-50%);
  width: 1.5rem;
  height: 1.5rem;
  border: 0;
  background: transparent;
  color: var(--color-text-muted);
}

.timeline-group-create:hover {
  background: var(--color-bg);
  color: var(--color-text);
}

.icon-plus {
  display: block;
  position: relative;
  width: 0.7rem;
  height: 0.7rem;
}

.icon-plus::before,
.icon-plus::after {
  content: "";
  position: absolute;
  background: currentColor;
}

.icon-plus::before {
  left: 50%;
  top: 0;
  width: 2px;
  height: 100%;
  margin-left: -1px;
}

.icon-plus::after {
  top: 50%;
  left: 0;
  height: 2px;
  width: 100%;
  margin-top: -1px;
}

.timeline-row {
  position: relative;
  width: 2880px;
  min-height: 2rem;
  margin-bottom: 4px;
  background: var(--color-bg-panel);
  cursor: pointer;
}

.timeline-row-track {
  position: absolute;
  inset: 0;
  width: 2880px;
}

.timeline-row-bars {
  position: absolute;
  inset: 0;
  width: 2880px;
}

.timeline-row-name {
  position: sticky;
  left: 0;
  z-index: 3;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;
  width: var(--timeline-view-width, 100%);
  min-height: 2rem;
  padding: 0 0.75rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: center;
  font-size: 0.8125rem;
  color: var(--color-text);
  pointer-events: none;
}

.timeline-row-checklist {
  margin-bottom: 2px;
  padding: 2px 0;
}

.timeline-row-checklist-name {
  justify-content: flex-start;
  gap: 0.375rem;
  padding-left: 1.5rem;
  font-size: 0.75rem;
  color: var(--color-text-tertiary);
  text-align: left;
}

.timeline-checklist-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.timeline-row-bar {
  position: absolute;
  top: 0;
  bottom: 0;
  z-index: 1;
  pointer-events: none;
  opacity: 0.5;
}

.timeline-row-bar-planned {
  opacity: 0.1;
  z-index: 1;
}

.timeline-row-bar-solid {
  opacity: 1;
  z-index: 2;
}

.timeline-row-bar-task {
  background: rgb(34, 197, 94);
}

.timeline-row-bar-action {
  background: rgb(59, 130, 246);
}

.timeline-row-bar-event {
  background: rgb(168, 85, 247);
}

.timeline-row-bar-task-overdue {
  background: rgb(220, 38, 38);
}

.timeline-row-bar-task-marker {
  z-index: 2;
  opacity: 0.5;
}

.timeline-row-bar-task-marker-start {
  background: rgb(34, 197, 94);
}

.timeline-row-bar-task-marker-due {
  background: rgb(220, 38, 38);
}

/* Вход и OAuth: форма по центру, без панелей приложения */

body.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  overflow: auto;
}

#auth-form,
#oauth-form,
.auth-shell .block--card {
  width: min(22rem, 100%);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 1.5rem;
  background: var(--color-bg-panel);
  border: none;
  border-radius: 0.5rem;
}

#auth-form h1,
#auth-form h2,
#oauth-form h1,
#oauth-form h2 {
  margin: 0;
}

#auth-form h2,
#oauth-form h2 {
  font-size: 1rem;
  font-weight: 600;
}

#auth-error,
#oauth-error {
  margin: 0;
  font-size: 0.875rem;
  color: #b91c1c;
}

.oauth-actions {
  display: flex;
  gap: 0.5rem;
}

.oauth-actions button {
  flex: 1;
}

#oauth-client,
#oauth-account {
  margin: 0;
  font-size: 0.875rem;
}

@media (display-mode: standalone), (display-mode: window-controls-overlay) {
  body.auth-page {
    -webkit-app-region: drag;
    app-region: drag;
  }

  body.auth-page form,
  body.auth-page button,
  body.auth-page input {
    -webkit-app-region: no-drag;
    app-region: no-drag;
  }
}

.theme-options {
  list-style: none;
  margin: 0.5rem 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-width: 20rem;
}

.theme-options__item {
  margin: 0;
}

.theme-option {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.75rem;
  border: none;
  border-radius: 0.25rem;
  background: var(--color-bg-panel);
  cursor: pointer;
}

.theme-option input {
  margin: 0;
}

.theme-option__label {
  flex: 1;
  color: var(--color-text);
}

.theme-option:has(input:checked) {
  background: var(--color-selected);
}

#settings-appearance .field__label {
  display: block;
  margin-top: 0.75rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--color-text);
}
