/* ── Telegram dark (default) ── */
:root,
html[data-skin="telegram"][data-mode="dark"] {
  --bg-app: #0e1621;
  --bg-header: #17212b;
  --bg-chat: #0e1621;
  --bg-input: #17212b;
  --bg-bubble-in: #182533;
  --bg-bubble-out: #2b5278;
  --bubble-out-text: #ffffff;
  --accent: #3390ec;
  --accent-hover: #2b7fd4;
  --accent-soft: rgba(51, 144, 236, 0.18);
  --accent-soft-hover: rgba(51, 144, 236, 0.28);
  --text: #f5f5f5;
  --text-secondary: #708499;
  --text-muted: #5d6e7e;
  --border: rgba(255, 255, 255, 0.08);
  --error-bg: rgba(229, 57, 53, 0.15);
  --error-text: #ffcdd2;
  --ok-bg: rgba(51, 144, 236, 0.12);
  --ok-text: #a8d4ff;
  --system-bg: rgba(0, 0, 0, 0.22);
  --system-text: #708499;
  --hint-bg: rgba(255, 255, 255, 0.06);
  --icon-hover: rgba(255, 255, 255, 0.06);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.28);
  --radius-bubble: 12px;
  --radius-input: 22px;
  --radius-send: 50%;
  --radius-chip: 16px;
  --radius-opt: 8px;
  --radius-avatar: 50%;
  --radius-panel: 12px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --avatar-grad: linear-gradient(135deg, #3390ec, #5eb3f6);
  --header-border: 1px solid var(--border);
  --composer-border: 1px solid var(--border);
  --chat-pattern-opacity: 0.018;
  --theme-color: #17212b;
  --panel-bg: #1e2c3a;
  --seg-bg: rgba(255, 255, 255, 0.06);
  --seg-active-bg: var(--accent);
  --seg-active-text: #fff;
}

/* ── Telegram light ── */
html[data-skin="telegram"][data-mode="light"] {
  --bg-app: #ffffff;
  --bg-header: #ffffff;
  --bg-chat: #8cabb8;
  --bg-input: #f0f0f0;
  --bg-bubble-in: #ffffff;
  --bg-bubble-out: #effdde;
  --bubble-out-text: #000000;
  --accent: #3390ec;
  --accent-hover: #2b7fd4;
  --accent-soft: rgba(51, 144, 236, 0.12);
  --accent-soft-hover: rgba(51, 144, 236, 0.22);
  --text: #000000;
  --text-secondary: #707579;
  --text-muted: #999999;
  --border: rgba(0, 0, 0, 0.08);
  --error-bg: rgba(229, 57, 53, 0.1);
  --error-text: #c62828;
  --ok-bg: rgba(51, 144, 236, 0.1);
  --ok-text: #1565c0;
  --system-bg: rgba(0, 0, 0, 0.28);
  --system-text: #ffffff;
  --hint-bg: rgba(0, 0, 0, 0.05);
  --icon-hover: rgba(0, 0, 0, 0.06);
  --shadow: 0 1px 1px rgba(0, 0, 0, 0.08);
  --chat-pattern-opacity: 0.12;
  --theme-color: #ffffff;
  --panel-bg: #ffffff;
  --seg-bg: #f0f0f0;
  --seg-active-bg: var(--accent);
  --seg-active-text: #fff;
}

/* ── ICQ dark ── */
html[data-skin="icq"][data-mode="dark"] {
  --bg-app: #1a1a2e;
  --bg-header: #16213e;
  --bg-chat: #0f0f1a;
  --bg-input: #252545;
  --bg-bubble-in: #2a2a4a;
  --bg-bubble-out: #3d2e00;
  --bubble-out-text: #ffe8a0;
  --accent: #ff9c00;
  --accent-hover: #ffb733;
  --accent-soft: rgba(255, 156, 0, 0.18);
  --accent-soft-hover: rgba(255, 156, 0, 0.3);
  --text: #f0f0f5;
  --text-secondary: #a0a0c0;
  --text-muted: #707090;
  --border: rgba(255, 156, 0, 0.25);
  --error-bg: rgba(229, 57, 53, 0.18);
  --error-text: #ffcdd2;
  --ok-bg: rgba(255, 156, 0, 0.12);
  --ok-text: #ffd480;
  --system-bg: rgba(255, 156, 0, 0.15);
  --system-text: #ffd480;
  --hint-bg: rgba(255, 156, 0, 0.1);
  --icon-hover: rgba(255, 156, 0, 0.15);
  --shadow: 2px 2px 0 rgba(0, 0, 0, 0.45);
  --radius-bubble: 4px;
  --radius-input: 4px;
  --radius-send: 4px;
  --radius-chip: 4px;
  --radius-opt: 4px;
  --radius-avatar: 4px;
  --radius-panel: 4px;
  --font: Tahoma, Verdana, "Segoe UI", sans-serif;
  --avatar-grad: linear-gradient(135deg, #ff9c00, #ff66aa 40%, #33ccff 80%);
  --header-border: 2px solid #ff9c00;
  --composer-border: 2px solid #ff9c00;
  --chat-pattern-opacity: 0.04;
  --theme-color: #16213e;
  --panel-bg: #1e1e3a;
  --seg-bg: #252545;
  --seg-active-bg: #ff9c00;
  --seg-active-text: #1a1a2e;
}

/* ── ICQ light (classic) ── */
html[data-skin="icq"][data-mode="light"] {
  --bg-app: #e8eef5;
  --bg-header: #ffcc00;
  --bg-chat: #d4e0f0;
  --bg-input: #ffffff;
  --bg-bubble-in: #ffffff;
  --bg-bubble-out: #fff8dc;
  --bubble-out-text: #333333;
  --accent: #0066cc;
  --accent-hover: #0052a3;
  --accent-soft: rgba(0, 102, 204, 0.1);
  --accent-soft-hover: rgba(0, 102, 204, 0.18);
  --text: #222222;
  --text-secondary: #555555;
  --text-muted: #888888;
  --border: #a0b0c8;
  --error-bg: #ffe0e0;
  --error-text: #b00000;
  --ok-bg: #fff3cc;
  --ok-text: #665500;
  --system-bg: #c8d4e8;
  --system-text: #445566;
  --hint-bg: #ffffff;
  --icon-hover: rgba(0, 0, 0, 0.08);
  --shadow: 1px 1px 2px rgba(0, 0, 0, 0.18);
  --radius-bubble: 3px;
  --radius-input: 3px;
  --radius-send: 3px;
  --radius-chip: 3px;
  --radius-opt: 3px;
  --radius-avatar: 3px;
  --radius-panel: 3px;
  --font: Tahoma, Verdana, "Segoe UI", sans-serif;
  --avatar-grad: linear-gradient(135deg, #ffcc00, #ff6699 45%, #33ccff);
  --header-border: 1px solid #cc9900;
  --composer-border: 2px solid #a0b0c8;
  --chat-pattern-opacity: 0.08;
  --theme-color: #ffcc00;
  --panel-bg: #ffffff;
  --seg-bg: #e8eef5;
  --seg-active-bg: #ffcc00;
  --seg-active-text: #333;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  color: var(--text);
  font-family: var(--font);
  background: var(--bg-app);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

#app {
  max-width: 680px;
  margin: 0 auto;
  height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--bg-app);
  box-shadow: 0 0 0 1px var(--border);
}

/* ── Header ── */

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 12px;
  background: var(--bg-header);
  border-bottom: var(--header-border);
  flex-shrink: 0;
  position: relative;
  z-index: 20;
}

.header-main {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.avatar {
  flex-shrink: 0;
  width: 42px;
  height: 42px;
  border-radius: var(--radius-avatar);
  background: var(--avatar-grad);
  display: grid;
  place-items: center;
  color: #fff;
}

html[data-skin="icq"] .avatar {
  color: #1a1a2e;
  border: 2px solid rgba(0, 0, 0, 0.15);
}

.avatar svg {
  width: 24px;
  height: 24px;
}

.header-info { min-width: 0; }

.header-info h1 {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

html[data-skin="icq"][data-mode="light"] .header-info h1,
html[data-skin="icq"][data-mode="light"] .header-status,
html[data-skin="icq"][data-mode="light"] .icon-btn {
  color: #333;
}

.header-status {
  margin: 1px 0 0;
  font-size: 0.8125rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

html[data-skin="icq"] .header-status::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 5px;
  border-radius: 50%;
  background: #3ddc84;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.2);
  vertical-align: middle;
}

.header-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
  align-items: center;
}

.icon-btn {
  width: 40px;
  height: 40px;
  padding: 0;
  border: none;
  border-radius: var(--radius-avatar);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background 0.15s, color 0.15s;
}

.icon-btn svg {
  width: 22px;
  height: 22px;
}

.icon-btn:hover {
  background: var(--icon-hover);
  color: var(--text);
}

.icon-btn:active {
  opacity: 0.85;
}

html[data-skin="icq"] .icon-btn {
  border: 1px solid transparent;
}

html[data-skin="icq"] .icon-btn:hover {
  border-color: var(--border);
}

/* ── Theme panel ── */

.theme-wrap {
  position: relative;
}

.theme-panel {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  width: 220px;
  padding: 12px;
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-panel);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  z-index: 30;
}

html[data-skin="icq"] .theme-panel {
  box-shadow: 3px 3px 0 rgba(0, 0, 0, 0.25);
  border-width: 2px;
}

.theme-section-label {
  margin: 0 0 6px;
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.theme-section-label:not(:first-child) {
  margin-top: 12px;
}

.theme-seg {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 3px;
  background: var(--seg-bg);
  border-radius: var(--radius-chip);
}

.theme-opt {
  padding: 7px 8px;
  border: none;
  border-radius: calc(var(--radius-chip) - 1px);
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.8125rem;
  font-family: var(--font);
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.theme-opt:hover {
  color: var(--text);
}

.theme-opt.is-active {
  background: var(--seg-active-bg);
  color: var(--seg-active-text);
}

/* ── Login ── */

.login {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  background: var(--bg-app);
}

.login-card {
  width: 100%;
  max-width: 360px;
  text-align: center;
}

html[data-skin="icq"] .login-card {
  padding: 20px;
  background: var(--bg-header);
  border: 2px solid var(--border);
  border-radius: var(--radius-panel);
  box-shadow: 4px 4px 0 rgba(0, 0, 0, 0.15);
}

html[data-skin="icq"][data-mode="dark"] .login-card {
  background: var(--bg-header);
}

.login-logo {
  width: 80px;
  height: 80px;
  margin: 0 auto 20px;
  border-radius: var(--radius-avatar);
  background: var(--avatar-grad);
  display: grid;
  place-items: center;
  color: #fff;
}

html[data-skin="icq"] .login-logo {
  color: #1a1a2e;
  border: 2px solid rgba(0, 0, 0, 0.12);
}

.login-logo svg {
  width: 44px;
  height: 44px;
}

.login-title {
  margin: 0 0 8px;
  font-size: 1.5rem;
  font-weight: 700;
}

html[data-skin="icq"][data-mode="light"] .login-title,
html[data-skin="icq"][data-mode="light"] .login-lead {
  color: #333;
}

.login-lead {
  margin: 0 0 28px;
  font-size: 0.9375rem;
  line-height: 1.45;
  color: var(--text-secondary);
}

#login-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

#login-form input[type="password"] {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-input);
  background: var(--bg-input);
  color: var(--text);
  font-size: 1rem;
  font-family: var(--font);
  outline: none;
  transition: border-color 0.15s;
}

html[data-skin="icq"] #login-form input[type="password"] {
  border-width: 2px;
}

#login-form input:focus {
  border-color: var(--accent);
}

#login-form button[type="submit"] {
  width: 100%;
  padding: 12px 16px;
  border: none;
  border-radius: var(--radius-input);
  background: var(--accent);
  color: #fff;
  font-size: 1rem;
  font-weight: 700;
  font-family: var(--font);
  cursor: pointer;
  transition: background 0.15s;
}

html[data-skin="icq"][data-mode="dark"] #login-form button[type="submit"],
html[data-skin="icq"][data-mode="light"] #login-form button[type="submit"] {
  color: var(--seg-active-text);
  border: 2px solid rgba(0, 0, 0, 0.2);
  box-shadow: 2px 2px 0 rgba(0, 0, 0, 0.15);
}

html[data-skin="icq"][data-mode="light"] #login-form button[type="submit"] {
  background: #ffcc00;
  color: #333;
}

#login-form button[type="submit"]:hover { background: var(--accent-hover); }
#login-form button[type="submit"]:disabled { opacity: 0.6; cursor: wait; }

html[data-skin="icq"][data-mode="light"] #login-form button[type="submit"]:hover {
  background: #ffd633;
}

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

/* ── Chat area ── */

#chat-view {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.chat-area {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='56' height='56' viewBox='0 0 56 56'%3E%3Cg fill='%23ffffff' fill-opacity='0.04'%3E%3Cpath d='M28 8c-2 0-3.5 1.5-3.5 3.5S26 15 28 15s3.5-1.5 3.5-3.5S30 8 28 8zm0 34c-2 0-3.5 1.5-3.5 3.5S26 49 28 49s3.5-1.5 3.5-3.5S30 42 28 42zM8 28c0-2 1.5-3.5 3.5-3.5S15 26 15 28s-1.5 3.5-3.5 3.5S8 30 8 28zm34 0c0-2 1.5-3.5 3.5-3.5S49 26 49 28s-1.5 3.5-3.5 3.5S42 30 42 28z'/%3E%3C/g%3E%3C/svg%3E"),
    var(--bg-chat);
}

html[data-skin="icq"] .chat-area {
  background:
    repeating-linear-gradient(
      -45deg,
      transparent,
      transparent 10px,
      rgba(255, 156, 0, 0.03) 10px,
      rgba(255, 156, 0, 0.03) 20px
    ),
    var(--bg-chat);
}

html[data-skin="icq"][data-mode="light"] .chat-area {
  background:
    repeating-linear-gradient(
      -45deg,
      transparent,
      transparent 10px,
      rgba(0, 102, 204, 0.04) 10px,
      rgba(0, 102, 204, 0.04) 20px
    ),
    var(--bg-chat);
}

.messages {
  height: 100%;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px 10px 16px;
  scrollbar-width: thin;
  scrollbar-color: var(--text-muted) transparent;
}

/* ── Bubbles ── */

.bubble {
  max-width: 78%;
  padding: 7px 12px 8px;
  line-height: 1.4;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.9375rem;
  box-shadow: var(--shadow);
}

.bubble.user {
  align-self: flex-end;
  background: var(--bg-bubble-out);
  color: var(--bubble-out-text);
  border-radius: var(--radius-bubble) var(--radius-bubble) 4px var(--radius-bubble);
}

.bubble.assistant {
  align-self: flex-start;
  background: var(--bg-bubble-in);
  color: var(--text);
  border-radius: var(--radius-bubble) var(--radius-bubble) var(--radius-bubble) 4px;
}

html[data-skin="icq"] .bubble.user,
html[data-skin="icq"] .bubble.assistant {
  border-radius: var(--radius-bubble);
  border: 1px solid var(--border);
}

.bubble.system {
  align-self: center;
  max-width: 90%;
  padding: 4px 10px;
  background: var(--system-bg);
  color: var(--system-text);
  font-size: 0.8125rem;
  text-align: center;
  border-radius: 10px;
  box-shadow: none;
}

html[data-skin="icq"] .bubble.system {
  border-radius: var(--radius-bubble);
  border: 1px dashed var(--border);
}

.bubble.error {
  align-self: stretch;
  max-width: none;
  background: var(--error-bg);
  color: var(--error-text);
  border-radius: var(--radius-bubble);
  font-size: 0.875rem;
  box-shadow: none;
}

.bubble.status {
  align-self: stretch;
  max-width: none;
  font-size: 0.8125rem;
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  white-space: pre-wrap;
  border-radius: var(--radius-bubble);
  box-shadow: none;
}

.bubble.status.ok {
  background: var(--ok-bg);
  color: var(--ok-text);
}

.bubble.status.error {
  background: var(--error-bg);
  color: var(--error-text);
}

/* ── Inline keyboard (options) ── */

.options {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 0 10px 8px;
}

.options button {
  width: 100%;
  padding: 10px 14px;
  border: none;
  border-radius: var(--radius-opt);
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.9375rem;
  font-family: var(--font);
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  transition: background 0.15s;
}

html[data-skin="icq"] .options button {
  border: 1px solid var(--border);
}

.options button:hover {
  background: var(--accent-soft-hover);
}

/* ── Composer ── */

.composer {
  flex-shrink: 0;
  padding: 8px 10px;
  padding-bottom: max(8px, env(safe-area-inset-bottom));
  background: var(--bg-header);
  border-top: var(--header-border);
}

html[data-skin="icq"][data-mode="light"] .composer {
  background: #f0f4fa;
}

.composer-inner {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 4px 4px 4px 16px;
  background: var(--bg-input);
  border-radius: var(--radius-input);
  border: var(--composer-border);
}

.composer-inner textarea {
  flex: 1;
  min-width: 0;
  max-height: 140px;
  padding: 8px 0;
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 1rem;
  font-family: var(--font);
  line-height: 1.35;
  outline: none;
  resize: none;
  overflow-y: auto;
}

.composer-inner textarea::placeholder {
  color: var(--text-muted);
}

.send-btn {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  padding: 0;
  border: none;
  border-radius: var(--radius-send);
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background 0.15s, opacity 0.15s;
}

html[data-skin="icq"][data-mode="dark"] .send-btn {
  color: #1a1a2e;
}

html[data-skin="icq"][data-mode="light"] .send-btn {
  background: #ffcc00;
  color: #333;
  border: 1px solid #cc9900;
}

.send-btn svg {
  width: 20px;
  height: 20px;
  margin-left: 2px;
}

.send-btn:hover { background: var(--accent-hover); }
.send-btn:disabled { opacity: 0.5; cursor: wait; }

html[data-skin="icq"][data-mode="light"] .send-btn:hover {
  background: #ffd633;
}

html[data-skin="icq"][data-mode="dark"] .send-btn:hover {
  background: #ffb733;
  color: #1a1a2e;
}

/* ── Hints ── */

.hints {
  flex-shrink: 0;
  background: var(--bg-header);
  border-top: 1px solid var(--border);
  max-height: 130px;
  overflow: hidden;
}

html[data-skin="icq"][data-mode="light"] .hints {
  background: #f0f4fa;
}

.hints-scroll {
  overflow-y: auto;
  padding: 8px 10px 10px;
  max-height: 130px;
}

.hints-label {
  margin: 0 0 6px;
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.hints-label:not(:first-child) {
  margin-top: 8px;
}

.hint-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.hint {
  padding: 6px 12px;
  border: none;
  border-radius: var(--radius-chip);
  background: var(--hint-bg);
  color: var(--text-secondary);
  font-size: 0.8125rem;
  font-family: var(--font);
  line-height: 1.3;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s, color 0.15s;
}

html[data-skin="icq"] .hint {
  border: 1px solid var(--border);
}

.hint:hover {
  background: var(--accent-soft);
  color: var(--accent);
}

[hidden] { display: none !important; }

@media (max-width: 520px) {
  #app {
    max-width: none;
    box-shadow: none;
  }

  .bubble { max-width: 85%; }

  .hints {
    max-height: 110px;
  }

  .hints-scroll {
    max-height: 110px;
  }

  .theme-panel {
    right: -8px;
  }
}

.main-tabs {
  display: flex;
  gap: 4px;
  padding: 8px 12px;
  background: var(--bg-header);
  border-bottom: var(--header-border);
}

.main-tab {
  flex: 1;
  position: relative;
  padding: 8px 12px;
  border: none;
  border-radius: var(--radius-opt);
  background: transparent;
  color: var(--text-secondary);
  font-family: var(--font);
  font-size: 0.875rem;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.main-tab.is-active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.inbox-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  margin-left: 6px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 0.6875rem;
  font-weight: 700;
  vertical-align: middle;
}

.inbox-list {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  background: var(--bg-chat);
  min-height: 0;
}

.inbox-empty {
  padding: 24px 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9375rem;
}

.inbox-card {
  background: var(--bg-bubble-in);
  border-radius: var(--radius-bubble);
  padding: 12px 14px;
  margin-bottom: 10px;
  box-shadow: var(--shadow);
}

.inbox-card.is-unread {
  border-left: 3px solid var(--accent);
}

.inbox-card-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: flex-start;
  margin-bottom: 6px;
}

.inbox-card-title {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.35;
}

.inbox-card-time {
  flex-shrink: 0;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.inbox-card-type {
  display: inline-block;
  margin-bottom: 6px;
  padding: 2px 8px;
  border-radius: var(--radius-chip);
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.inbox-card-body {
  white-space: pre-wrap;
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.45;
  margin-bottom: 10px;
}

.inbox-card-actions {
  display: flex;
  gap: 8px;
}

.inbox-card-actions button {
  padding: 6px 10px;
  border: none;
  border-radius: var(--radius-opt);
  background: var(--hint-bg);
  color: var(--text-secondary);
  font-family: var(--font);
  font-size: 0.8125rem;
  cursor: pointer;
}

.inbox-card-actions button:hover {
  background: var(--accent-soft);
  color: var(--accent);
}

#inbox-view {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

#app:has(#inbox-view:not([hidden])),
#app:has(#chat-view:not([hidden])),
#app:has(#home-view:not([hidden])),
#app:has(#diary-view:not([hidden])),
#app:has(#people-view:not([hidden])) {
  display: flex;
  flex-direction: column;
}

#chat-view {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.page-view {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.page-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 14px 12px 24px;
  background: var(--bg-chat);
}

.dash-hero {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.dash-kicker {
  margin: 0 0 4px;
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.dash-title {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1.15;
}

.dash-cta {
  flex-shrink: 0;
  padding: 10px 16px;
  border: none;
  border-radius: var(--radius-input);
  background: var(--accent);
  color: #fff;
  font-family: var(--font);
  font-size: 0.875rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: var(--shadow);
}

html[data-skin="icq"][data-mode="light"] .dash-cta {
  background: #ffcc00;
  color: #333;
}

.dash-cta:hover { background: var(--accent-hover); }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 16px;
}

.stat-card {
  padding: 12px;
  border-radius: var(--radius-bubble);
  background: var(--bg-bubble-in);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

.stat-label {
  margin: 0 0 6px;
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.stat-value {
  margin: 0;
  font-size: clamp(1rem, 3.6vw, 1.25rem);
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}

.stat-meta {
  margin: 6px 0 0;
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.panel-block {
  margin-bottom: 14px;
  padding: 12px;
  border-radius: var(--radius-bubble);
  background: var(--bg-bubble-in);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.panel-head h3 {
  margin: 0;
  font-size: 0.9375rem;
  font-weight: 700;
}

.entry-list,
.cat-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.entry-row,
.cat-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}

.entry-row:last-child,
.cat-row:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.entry-main {
  min-width: 0;
}

.entry-title {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.entry-sub {
  margin: 2px 0 0;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.entry-amount {
  flex-shrink: 0;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text);
}

.cat-bar-wrap {
  flex: 1;
  height: 6px;
  border-radius: 999px;
  background: var(--hint-bg);
  overflow: hidden;
  margin: 0 10px;
}

.cat-bar {
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
}

.browse-empty,
.browse-error {
  margin: 0;
  padding: 20px 8px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9375rem;
}

.browse-error { color: var(--error-text); }

.browse-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 14px;
}

.browse-label {
  font-size: 0.8125rem;
  color: var(--text-secondary);
}

.browse-input {
  flex: 1;
  min-width: 140px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-input);
  background: var(--bg-input);
  color: var(--text);
  font-family: var(--font);
  font-size: 0.9375rem;
}

.browse-btn {
  padding: 10px 14px;
  border: none;
  border-radius: var(--radius-input);
  background: var(--accent);
  color: #fff;
  font-family: var(--font);
  font-weight: 700;
  font-size: 0.875rem;
  cursor: pointer;
}

.browse-btn:hover { background: var(--accent-hover); }

.browse-content {
  padding: 4px 0 12px;
}

.diary-entry {
  padding: 12px;
  margin-bottom: 8px;
  border-radius: var(--radius-bubble);
  background: var(--bg-bubble-in);
  border: 1px solid var(--border);
}

.diary-entry-time {
  margin: 0 0 4px;
  font-size: 0.75rem;
  color: var(--accent);
  font-weight: 600;
}

.diary-entry-text {
  margin: 0;
  font-size: 0.9375rem;
  line-height: 1.45;
  white-space: pre-wrap;
}

.people-layout {
  display: grid;
  grid-template-columns: minmax(140px, 34%) 1fr;
  gap: 12px;
  align-items: start;
}

.people-sidebar {
  position: sticky;
  top: 0;
}

.people-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: calc(100vh - 220px);
  overflow-y: auto;
}

.person-chip {
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: var(--radius-opt);
  background: var(--bg-bubble-in);
  color: var(--text);
  font-family: var(--font);
  font-size: 0.875rem;
  cursor: pointer;
}

.person-chip:hover,
.person-chip.is-active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

.person-detail h3 {
  margin: 0 0 6px;
  font-size: 1.25rem;
}

.person-aliases {
  margin: 0 0 14px;
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.fact-item {
  padding: 10px 12px;
  margin-bottom: 8px;
  border-radius: var(--radius-bubble);
  background: var(--bg-bubble-in);
  border: 1px solid var(--border);
  font-size: 0.9375rem;
  line-height: 1.45;
}

@media (max-width: 520px) {
  .stat-grid {
    grid-template-columns: 1fr;
  }

  .main-tabs {
    overflow-x: auto;
    flex-wrap: nowrap;
  }

  .main-tab {
    flex: 0 0 auto;
    white-space: nowrap;
  }

  .people-layout {
    grid-template-columns: 1fr;
  }

  .people-list {
    max-height: 180px;
    flex-direction: row;
    flex-wrap: wrap;
  }

  .person-chip {
    width: auto;
  }
}

