/* ============================================
   CSS Custom Properties (Theme Variables)
   ============================================ */
:root {
  /* Theme colors - dynamically set by ThemeManager */
  --color-primary: #09225a;
  --color-secondary: #6a11cb;
  --color-accent: #2575fc;
  --color-gradient-start: #1d11cb;
  --color-gradient-end: #004da5;
  --color-border: #8ab4f8;
  --color-border-light: #d0e8ff;
  --color-background: #f7fbff;
  --color-background-light: #c7deff;
  --color-background-alt: #f3fbff;
  --color-background-dark: #f0f9ff;
  --color-surface: #ffffff;
  --color-surface-hover: #f2f8ff;
  --color-surface-active: #d0e8ff;
  --color-text: #495057;
  --color-text-secondary: #6c757d;
  --color-text-tertiary: #6b7280;
  --color-success: #28a745;
  --color-warning: #ffc107;
  --color-danger: #dc3545;
  --color-info: #17a2b8;

  /* Modal variables */
  --modal-exit-ms: 220ms;
  --base-modal-exit-ms: 220ms;
  --base-modal-small: min(90vw, 400px);
  --base-modal-medium: min(92vw, 640px);
  --base-modal-large: min(95vw, 1000px);
  --base-modal-fullscreen: 100vw;
  --base-modal-backdrop: rgba(0,0,0,.45);
  --base-modal-shadow: 0 10px 30px rgba(0,0,0,.2);
  --base-modal-border-radius: 12px;
  --base-modal-header-bg: linear-gradient(90deg, var(--color-gradient-start), var(--color-gradient-end));
  --base-modal-z-index: 2000;
}

/* Smooth transitions for theme changes */
* {
  scrollbar-width: thin;
  scrollbar-color: rgba(120,120,150,0.45) rgba(255,255,255,0.15);
  transition:
    background-color 0.8s ease-in-out,
    border-color 0.8s ease-in-out,
    color 0.8s ease-in-out,
    background 0.8s ease-in-out;
}

::-webkit-scrollbar-track {
  background: rgba(255,255,255,0.05);
  backdrop-filter: blur(8px);
}

/* Disable transitions for interactive elements to keep them snappy */
button, input, textarea, select, a {
  transition:
    background-color 0.2s ease,
    border-color 0.2s ease,
    color 0.2s ease,
    transform 0.2s ease,
    opacity 0.2s ease;
}

/* ============================================
   Main Layout
   ============================================ */
#chatbot-container {
  font-family: 'Inter', sans-serif;
  background-image: url("/img/icai-header-a.jpg");
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
/*
  background: linear-gradient(135deg, var(--color-background-alt) 0%, var(--color-background-dark) 100%);
 */
  padding: 8px;
  height: 100vh;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
}

.chat-wrapper {
  display: flex;
  border: 1px solid rgb(from var(--color-border) r g b / 0.85);
  /*border: 1px solid var(--color-border);*/
  border-radius: 12px;
  flex: 1;
  min-height: 0;
  min-width: 0;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.05);
  overflow: hidden;
  background: rgb(from var(--color-surface) r g b / 0.2);
/*  background: var(--color-surface);*/
}

.threads {
  width: 220px;
  flex: 0 0 220px; /* keep sidebar width stable on wide screens */
  flex-shrink: 0;
  border-right: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  /*background: rgb(from var(--color-background) r g b / 0.4);*/
    /*  background: var(--color-background);*/
  transition: transform 0.5s ease, opacity 0.5s ease, filter 0.5s ease, width 0.5s ease;
}

.threads-list {
  flex: 1;
  overflow: auto;
  padding: 8px;
}

.thread-item {
  display: flex;
  gap: 4px;
  margin-bottom: 6px;
}

.icon {
  width: 1em;
  height: 1em;
  stroke: currentColor;
  fill: none;
}
.thread-item .thread-btn {
  flex: 1;
  border: none;
  background: var(--color-surface-hover);
  padding: 6px 0;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.2s;
}

.thread-menu {
  position: absolute;
  background: var(--color-surface);
  border: 1px solid #cbd5e1;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
  border-radius: 4px;
  display: none;
  flex-direction: column;
  z-index: 1000;
}
.thread-menu button {
  border: none;
  background: none;
  padding: 4px 8px;
  text-align: left;
  cursor: pointer;
}
.thread-menu button:hover {
  background: #f0f0f0;
}

.active-thread {
  font-weight: 600;
  background: var(--color-surface-active);
}

.new-thread,
.open-settings {
  width: 100%;
  background: rgb(from var(--color-primary) r g b / 0.95);
  color: #fff;
  border: none;
  padding: 6px 0;
  cursor: pointer;
  border-radius: 6px;
  margin-top: 6px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
}

.new-thread:hover,
.open-settings:hover,
.chat-send:hover {
  filter: brightness(0.9);
}

.chat {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: rgb(from var(--color-surface) r g b / 0.1);
/*  background: var(--color-surface);*/
  min-height: 0;
  min-width: 0; /* allow bubble overflow without stretching layout */
}

.chat-messages {
  flex: 1;
  overflow: auto;
  min-width: 0;
  padding: 16px;
  /* background: rgb(from var(--color-background) r g b / 0.8);*/
  /*background: var(--color-background-light);*/
}

.input-area {
  display: flex;
  flex-direction: column;
  border-top: 1px solid var(--color-border);
  padding: 8px;
  background: rgb(from var(--color-background) r g b / 0.6);
  /*background: var(--color-background);*/
  flex-shrink: 0;
}

.input-row {
  display: flex;
  margin-top: 8px;
}

.input-row.drag-over, .chat-input.drag-over {
  border: 1px dashed #4e8df5;
  background: #f5f8ff;
}

.input-warning {
  color: gray;
  font-size: small;
}
.input-warning .upload-spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid #4e8df5;
  border-top-color: transparent;
  border-radius: 50%;
  margin-right: 6px;
  animation: spin 0.8s linear infinite;
  vertical-align: middle;
}
.input-warning.upload-error {
  color: #dc3545;
}
@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}
.rag-container {
  position: relative;
  display: flex;
  align-items: center;
  min-height: 24px;
}

.rag-rewriter-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-left: 8px;
  width: 26px;
  height: 26px;
  border-radius: 7px;
  border: 1px solid #cbd5e1;
  background: #f8fafc;
  color: #94a3b8;
  cursor: pointer;
  transition: all 0.18s ease;
}

.rag-rewriter-toggle:hover {
  border-color: #0ea5e9;
  color: #0ea5e9;
  box-shadow: 0 2px 8px rgba(14, 165, 233, 0.18);
}

.rag-rewriter-toggle.active {
  background: #e0f2fe;
  border-color: #0ea5e9;
  color: #0284c7;
  box-shadow: inset 0 0 0 1px rgba(2, 132, 199, 0.3);
}

.model-badge {
  margin-left: auto;
  font-size: 12px;
  padding: 2px 8px;
  border: 1px solid #cbd5e1;
  border-radius: 8px; /* rounded-square */
  background: #fff;
  color: #555;
  line-height: 1.2;
}

.chat-input {
  flex: 1;
  resize: none;
  padding: 8px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font-family: inherit;
  transition: height 120ms ease;
  max-height: 50vh; /* expand up to half of viewport */
  overflow-y: hidden; /* will switch to auto in JS when capped */
  background: rgb(from var(--color-background) r g b / 0.85);
}

.rag-domain-select {
  padding: 4px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: #fff;
}

.rag-domain-select-area {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}

.rag-domain-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.rag-domain-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 999px;
  background: #fff;
  color: #0f172a;
  font-size: 0.9em;
  cursor: pointer;
  transition: all 0.2s ease;
}

.rag-domain-tab:hover {
  border-color: var(--color-primary);
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.1);
}

.rag-domain-tab.active {
  background: var(--color-primary);
  color: #fff;
  border-color: var(--color-primary);
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.2);
}

.rag-domain-tab-color {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.5);
}

.rag-domain-tab-label {
  white-space: nowrap;
}

.rag-domain-overflow {
  margin-left: auto;
  position: relative;
}

.rag-domain-overflow-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 999px;
  border: 1px solid #cbd5e1;
  background: #fff;
  color: #0f172a;
  font-size: 1rem;
  cursor: pointer;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.rag-domain-overflow-button:hover,
.rag-domain-overflow-button[aria-expanded="true"] {
  border-color: var(--color-primary);
  box-shadow: 0 4px 10px rgba(15, 23, 42, 0.15);
}

.rag-domain-overflow-dropdown {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  background: #fff;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 8px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.15);
  z-index: 10;
}

.rag-domain-overflow-select {
  min-width: 200px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  padding: 6px 10px;
  background: #fff;
}

.rag-tags {
  display: flex;
  gap: 4px;
}

.rag-tag {
  font-size: 0.875rem;
  padding: 2px 6px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: #fff;
  display: flex;
  align-items: center;
}

.rag-tag-close {
  margin-left: 4px;
  cursor: pointer;
}


.rag-overlay {
  position: absolute;
  bottom: calc(100% + 4px);
  left: 0;
  display: flex;
  flex-direction: column;
  background: #fff;
  padding: 8px;
  border-radius: 8px;
  border: 1px solid #cbd5e1;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
  transform: translateY(16px);
  opacity: 0;
  filter: blur(3px);
  pointer-events: none;
  transition: transform 0.2s ease, opacity 0.2s ease, filter 0.2s ease;
  z-index: 10;
}

.rag-overlay.open {
  transform: translateY(0);
  opacity: 1;
  filter: blur(0);
  pointer-events: auto;
}

.rag-clear {
  margin-top: 4px;
  align-self: flex-end;
  background: #f0f0f0;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  padding: 2px 6px;
  cursor: pointer;
  font-size: 0.75rem;
}

.chat-send {
  background: rgb(from var(--color-primary) r g b / 0.95);;
  color: #fff;
  border: none;
  padding: 0 16px;
  margin-left: 8px;
  border-radius: 6px;
  cursor: pointer;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}
.chat-send.disabled,
.chat-send:disabled {
  background: #cbd5e1;
  color: #6b7280;
  cursor: not-allowed;
}
.chat-input:disabled {
  background: #f5f6f8;
  color: #9aa3af;
}

.settings {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(4px);
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.settings-dialog {
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(12px);
  padding: 16px;
  width: 80vw;
  max-width: 1000px;
  min-width: 400px;
  height: 80vh;
  border-radius: 12px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
  display: flex;
  flex-direction: column;
  position: relative;
  overflow-y: auto;
}

.settings-title {
  font-weight: 600;
  margin-bottom: 8px;
  margin-top: 0px;
}

.settings-content {
  display: flex;
  flex-direction: row;
  height: 100%;
  overflow: hidden;
}

.settings-sidebar {
  /* width: 140px; */
  border-right: 1px solid #cbd5e1;
  padding-right: 8px;
}

.settings-menu-item {
  padding: 4px;
  cursor: pointer;
  display: flex;
  flex-wrap: nowrap;
  text-space: nowrap;
  font-family: sans-serif;

}

.settings-menu-item.active {
  font-weight: 600;
  color: var(--color-primary);
  background: var(--color-background-alt);
  border: 1px solid var(--color-border);
  border-radius: 6px;
}

.settings-pane {
  flex: 1;
  padding-left: 8px;
  height: 100% !important;
  overflow-y: auto;
}

.domain-list {
  list-style: none;
  padding: 0;
}

.domain-list li button {
  margin-left: 4px;
  background: none;
  border: none;
  cursor: pointer;
}


.rag-url-list {
  width: 100%;
  box-sizing: border-box;
  margin-top: 6px;
  font-size: 0.9em;
}

.rag-pane textarea {
  width: 100%;
  box-sizing: border-box;
}

.rag-import-controls {
  display: flex;
  gap: 8px;
  margin-top: 6px;
}

.rag-status {
  white-space: pre-wrap;
  margin-top: 6px;
  font-size: 0.9em;
}

/* 古いrag-log-dialog CSSは削除済み - 新しいLogViewerModalを使用 */

.settings-close {
  position: absolute;
  top: 8px;
  right: 8px;
}
.close-settings {
  background: none;
  border: none;
  cursor: pointer;
  color: #333;
  font-size: 20px;
  line-height: 1;
}
.settings-back {
  display: none;
  position: absolute;
  top: 32px;
  left: 8px;
}
.back-settings {
  background: none;
  border: none;
  cursor: pointer;
  color: #333;
}

.message-user,
.message-assistant {
  display: flex;
  flex-direction: column;
  margin-bottom: 10px;
}

.message-user {
  align-items: flex-end;
}

.message-assistant {
  align-items: flex-start;
}

.bubble {
  padding: 10px 12px;
  border-radius: 12px;
  max-width: 95%;
  white-space: pre-wrap;
  line-height: 1.5;
  position: relative;
  overflow-x: auto;       /* long, unbroken text scrolls inside the bubble */
}

.bubble p,
.bubble ul,
.bubble ol,
.bubble li,
.bubble h1, .bubble h2, .bubble h3,
.bubble h4, .bubble h5, .bubble h6 {
  white-space: normal;   /* 改行を行として描画しない */
  margin: 0;             /* 余白も詰めるなら */
}

.message-user .bubble {
  background: rgb(from var(--color-background-light) r g b / 0.9);
}

.message-assistant .bubble {
  background: rgb(from var(--color-background-alt) r g b / 0.85);
}

/* Thought bubble styles */
.thought-bubble {
  position: relative;
}

.thought-bubble .bubble {
  background: var(--color-background-light);
  border-left: 4px solid var(--color-primary);
  transition: all 0.3s ease;
}

.thought-bubble.collapsed .bubble-content {
  display: none;
}

.thought-toggle {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 14px;
  color: var(--color-secondary);
  padding: 2px 6px;
  margin-left: 8px;
  border-radius: 4px;
  transition: background-color 0.2s ease;
}

.thought-toggle:hover {
  background-color: var(--color-surface-hover);
}

.chat hr {
  height: 1px;
  border: none;
  border-top: 1px dotted #00a0de;
  margin: 1rem 0;
}

.chat table{
    width: 100%;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.14);
}

.chat table tr th,
.chat table tr td {
  border: 1px solid #e6ebec;
  padding: 14px;
}

.chat table tr th {
  background: var(--color-primary);
  color: #fff;
  font-weight: bold;
}

.chat table tr:nth-of-type(odd) {
  background: var(--color-surface-hover);
}

.chat blockquote {
    position: relative;
    padding: 5px;
    box-sizing: border-box;
    background: #f5f5f5;
    color: #777777;
    font-family: serif;
    border-left: 4px solid var(--color-primary);
    margin: 4px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.14);
}

.chat blockquote strong{
  font-family: sans-serif;
}

.header {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;

  height: 72px;
  padding: 0 24px;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.12);
/*
  flex-shrink: 0;
  color: var(--color-secondary);
  border-radius: 8px;
  gap: 16px;
 */
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* フルロゴ（SVG） */
.logo svg#infinicloud-logo {
  height: 32px;      /* 高さだけ決めておけばOK */
  width: auto;
}

/* タイトル部分（縦2行） */
.header-title {
  display: flex;
  flex-direction: column;
  justify-content: center;
}


.header-title .logo svg {
  height: 40px;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.2));
}

/* 「AI」 */
.header-title .product-name-ai {
  font-family: "Inter", "Noto Sans JP", system-ui, -apple-system, sans-serif;
  font-size: 21px;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: #1b2550;
  vertical-align: 10px;
  text-shadow: 0px 0px 2px #555555;
}

/* 「— Shiraito Engine —」 */
.header-title .product-subtitle {
  margin-top: 2px;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: #51608c;
}

/*
.header-title h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
}
*/

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-left: auto;
}

.session-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.auth-login-link {
  color: var(--color-accent);
  font-weight: 600;
  text-decoration: none;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  padding: 6px 12px;
  background: var(--color-background);
  transition: background-color 0.2s ease, color 0.2s ease;
}

.auth-login-link:hover {
  background: var(--color-accent);
  color: #fff;
}

.auth-user {
  position: relative;
  display: flex;
  align-items: center;
}

.auth-user.step-up-active {
  background: rgba(248, 113, 113, 0.15);
  border-radius: 999px;
  padding: 2px 4px;
  transition: background-color 0.2s ease;
}

.auth-user.step-up-active .auth-user-trigger {
  background: #fee2e2;
  border-color: #f87171;
  color: #b91c1c;
}

.auth-user.step-up-active .auth-user-trigger:hover,
.auth-user.step-up-active .auth-user-trigger[aria-expanded="true"] {
  background: #fecaca;
}

.auth-user-trigger {
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-secondary);
  border-radius: 999px;
  padding: 6px 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.2s ease;
  display: inline-flex;
  align-items: center;
}

.auth-user-trigger:hover,
.auth-user-trigger[aria-expanded="true"] {
  background: var(--color-surface-hover);
}

.auth-user-trigger::after {
  content: '\25BE';
  margin-left: 6px;
  font-size: 12px;
}

.auth-user-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
  min-width: 160px;
  padding: 4px;
  display: flex;
  flex-direction: column;
  z-index: 40;
}

.auth-user-menu[hidden] {
  display: none !important;
}

.auth-logout-button {
  border: none;
  background: transparent;
  color: var(--color-secondary);
  text-align: left;
  padding: 8px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 500;
}

.auth-logout-button:hover {
  background: var(--color-surface-active);
  color: var(--color-danger);
}

/* ============================================
   Authentication Page
   ============================================ */

.auth-page {
  min-height: 100vh;
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--color-background-alt) 0%, var(--color-background-dark) 100%);
  font-family: 'Inter', sans-serif;
  padding: 24px;
}

.auth-card {
  width: min(560px, 100%);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 16px;
  box-shadow: 0 16px 32px rgba(0, 0, 0, 0.08);
  padding: 32px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.auth-card-header h1 {
  margin: 0 0 8px;
  font-size: 24px;
  color: var(--color-secondary);
}

.auth-card-header p {
  margin: 0;
  color: var(--color-text-secondary);
  line-height: 1.6;
}

.auth-section {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.auth-section h2 {
  margin: 0;
  font-size: 18px;
  color: var(--color-text);
}

.auth-expand-toggle {
  align-self: flex-start;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-secondary);
  border-radius: 999px;
  padding: 6px 12px;
  cursor: pointer;
  font-weight: 600;
}

.auth-expand-toggle:hover {
  background: var(--color-surface-hover);
}

.auth-expand-panel {
  border: 1px solid var(--color-border);
  border-radius: 12px;
  padding: 16px;
  background: var(--color-surface);
}

.auth-section-note {
  margin: 0;
  font-size: 14px;
  color: var(--color-text-secondary);
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.auth-hidden {
  display: none;
}

.auth-form-actions {
  display: flex;
  gap: 12px;
  justify-content: space-between;
}

.auth-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-weight: 600;
  color: var(--color-text);
}

.password-field {
  display: flex;
  align-items: center;
  gap: 6px;
}

.password-field input {
  flex: 1;
}

.password-toggle {
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-secondary);
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 12px;
  cursor: pointer;
}

.password-toggle:hover {
  background: var(--color-surface-hover);
}

.auth-form input {
  border: 1px solid var(--color-border);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 15px;
  background: var(--color-background);
  color: var(--color-text);
}

.auth-form input:focus {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px rgba(37, 117, 252, 0.16);
}

.auth-primary-button,
.auth-secondary-button {
  border: none;
  border-radius: 999px;
  padding: 10px 16px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.auth-primary-button {
  background: linear-gradient(135deg, var(--color-secondary), var(--color-primary));
  color: #fff;
  box-shadow: 0 8px 16px rgba(37, 117, 252, 0.25);
}

.auth-secondary-button {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  color: var(--color-secondary);
}

.auth-primary-button:hover,
.auth-secondary-button:hover {
  transform: translateY(-1px);
}

.auth-primary-button:disabled,
.auth-secondary-button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.auth-card-footer {
  display: flex;
  justify-content: flex-end;
}

.auth-link {
  color: var(--color-secondary);
  text-decoration: none;
  font-weight: 600;
}

.auth-link:hover {
  text-decoration: underline;
}

.auth-message {
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 14px;
  display: none;
}

.auth-message-info {
  display: block;
  background: rgba(37, 117, 252, 0.1);
  color: var(--color-secondary);
}

.auth-message-error {
  display: block;
  background: rgba(220, 53, 69, 0.1);
  color: var(--color-danger);
}

.auth-message-success {
  display: block;
  background: rgba(40, 167, 69, 0.12);
  color: var(--color-success);
}

.is-loading {
  position: relative;
}

.is-loading::after {
  content: '…';
  margin-left: 4px;
}

@media (max-width: 640px) {
  .auth-card {
    padding: 24px;
  }
}

.info-email-form {
  display: flex;
  gap: 8px;
  align-items: center;
  margin: 8px 0;
}

.info-email-form input {
  flex: 1;
}

.info-email-status {
  font-size: 14px;
  margin-top: 4px;
}

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

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

.info-email-status-pending {
  color: var(--color-text-secondary);
}

.info-summary-card {
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 12px;
  background: #ffffff;
  padding: 14px 18px;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.05);
  margin: 8px 0 16px;
}

.info-summary-card p {
  margin: 6px 0;
  line-height: 1.6;
}

.info-summary-card h4 {
  margin-top: 12px;
  margin-bottom: 6px;
}

.info-summary-card ul {
  margin: 8px 0 0;
  padding-left: 20px;
}

.info-health-process ul li {
  margin-bottom: 2px;
}

.info-domain-hint {
  margin: 0 0 8px;
  font-size: 0.9em;
  color: var(--color-text-secondary);
}

.info-domain-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.info-domain-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.2s ease;
}

.info-domain-item:hover {
  background: rgba(15, 23, 42, 0.05);
}

.info-domain-name {
  font-weight: 600;
}

.info-domain-perms {
  color: var(--color-text-secondary);
  font-size: 0.9em;
}

.info-domain-flags {
  margin-left: 6px;
  font-size: 0.85em;
  color: var(--color-text-secondary);
}

.info-domain-action {
  margin-left: auto;
  font-size: 0.85em;
  color: var(--color-text-tertiary, #9ca3af);
}

.info-model-variants {
  margin-top: 14px;
}

.info-model-variants ul {
  margin: 6px 0 0;
  padding-left: 18px;
}

.info-model-variants li {
  margin-bottom: 4px;
}

.info-variant-slot {
  display: inline-block;
  min-width: 36px;
  font-weight: 600;
  color: var(--color-secondary, #2563eb);
}

.thinking-wrapper {
  display: inline-block;
  animation: rotate-bounce 1s cubic-bezier(0.34, 1.56, 0.64, 1) infinite;
}

.thinking-logo {
  height: 2.1em;
  vertical-align: middle;
}

.thinking-logo path {
  transform-box: fill-box;
  transform-origin: center;
}

.thinking-logo .path1 {
  animation: beat1 1s cubic-bezier(0.34, 1.56, 0.64, 1) infinite;
}

.thinking-logo .path2 {
  animation: beat2 1s cubic-bezier(0.34, 1.56, 0.64, 1) infinite;
}

.thinking-logo .path3 {
  animation: beat3 1s cubic-bezier(0.34, 1.56, 0.64, 1) infinite;
}

.thinking-wrapper.exit {
  position: absolute;
  top: 15px;
  left: 15px;
  /* transform: translate(-50%, -50%); */
  animation: fade-out 0.7s forwards;
  pointer-events: none;
  z-index: 2000;
}

@keyframes fade-out {
  from {
    transform: scale(1);
    opacity: 1;
    filter: blur(0);
  }
  to {
    transform: scale(6);
    opacity: 0;
    filter: blur(16px);
  }
}

@keyframes rotate-bounce {
  0% { transform: rotate(0deg); }
  30% { transform: rotate(380deg); }
  50% { transform: rotate(360deg); }
  80% { transform: rotate(360deg); }
  100% { transform: rotate(360deg); }
}

@keyframes beat1 {
  0%, 50%, 80%, 100% { transform: translate(0, 0); }
  65% { transform: translate(0, -8%); }
  75% { transform: translate(0, 2%); }
}

@keyframes beat2 {
  0%, 50%, 80%, 100% { transform: translate(0, 0); }
  65% { transform: translate(-8%, 8%); }
  75% { transform: translate(2%, -2%); }
}

@keyframes beat3 {
  0%, 50%, 80%, 100% { transform: translate(0, 0); }
  65% { transform: translate(8%, 8%); }
  75% { transform: translate(-2%, -2%); }
}

.message-controls {
  text-align: right;
  margin-top: 4px;
}

.message-controls button {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 16px;
  margin-left: 4px;
  color: #666;
}

.message-controls button:hover {
  color: #000;
}

h1 {
  margin-left: 1em;
  font-size: x-large;
  margin-top: 0px;
  margin-bottom: 6px;
}

.open-thread-list {
  display: none;
  margin-left: auto;
  background: rgb(from var(--color-primary) r g b / 0.95);
  color: #fff;
  border: none;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
}

.thread-overlay-bg {
  display: none;
  opacity: 0;
  transition: opacity 0.5s ease;
}

.show-thread-overlay .thread-overlay-bg {
  display: block;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.4);
  opacity: 1;
  z-index: 999;
}

@media (max-width: 600px) {
  .threads {
    display: flex;
    width: 0px;
    flex: 0 0 0px; /* collapse sidebar when hidden on narrow screens */
    transform: translateX(-100%);
    opacity: 0;
    filter: blur(3px);
    z-index: 10;
    transition: transform 0.5s ease, opacity 0.5s ease, filter 0.5s ease, width 0.5s ease;
  }
  .open-thread-list {
    display: block;
  }
  .show-thread-overlay .threads {
    display: flex;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 220px;
    z-index: 1000;
    background: var(--color-background);
    transform: translateX(0);
    opacity: 1;
    filter: blur(0);
  }
}

@media (max-width: 600px) {
  .settings-title {
    margin-top: 32px;
  }
  .settings-dialog {
    width: 100vw;
    width: 90vw !important;
    height: 100vh;
    height: 80vh !important;
    max-width: none;
    max-width: 1200px !important;
    border-radius: 0;
    max-height: 800px !important;
  }
  .settings-content {
    flex-direction: column;
  }
  .settings-sidebar {
    width: 100%;
    border-right: none;
    padding-right: 0;
    margin-bottom: 8px;
  }
  .settings-back {
    display: block;
  }
  .settings-close {
    display: none;
  }
}


/* System Role Editing Styles */
.domain-system-role-editor {
  background: #f8f9fa;
  border: 1px solid #dee2e6;
  border-radius: 8px;
  padding: 16px;
  margin: 8px 0;
  overflow: hidden;
}

.domain-system-role-editor h4 {
  margin-top: 0;
  margin-bottom: 8px;
  color: #495057;
}

.domain-system-role-editor p {
  margin-bottom: 12px;
  color: #6c757d;
  font-size: 0.9em;
}

.system-role-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.04);
}

.system-role-form label {
  font-weight: 500;
  color: #495057;
}

.current-domain-name {
  font-weight: 600;
  color: var(--color-primary);
}

.system-role-input {
  width: 100%;
  padding: 8px;
  border: 1px solid #ced4da;
  border-radius: 4px;
  font-family: inherit;
  font-size: 0.9em;
  line-height: 1.4;
  resize: vertical;
  min-height: 80px;
}

.system-role-input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 2px var(--color-surface-hover);
}

.system-role-buttons {
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: flex-start;
  flex-wrap: wrap;
}

.system-role-save,
.system-role-cancel {
  padding: 6px 16px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9em;
  font-weight: 500;
}

.system-role-save {
  border: none;
}

.system-role-cancel {
  border: 1px solid #6c757d;
  background: transparent;
  color: #6c757d;
  transition: background-color 0.2s, color 0.2s;
}

.system-role-cancel:hover {
  background: #6c757d;
  color: #fff;
}

.color-description {
  margin-top: 0;
  margin-bottom: 8px;
  color: #6c757d;
  font-size: 0.9em;
}

.knowledge-link-description {
  margin-top: 0;
  margin-bottom: 12px;
  color: #5c636a;
  font-size: 0.9em;
}

.open-knowledge-button {
  align-self: flex-start;
  padding: 8px 18px;
  border-radius: 999px;
  border: none;
  background: var(--color-primary);
  color: #fff;
  font-weight: 600;
  font-size: 0.9em;
  cursor: pointer;
  box-shadow: 0 6px 16px rgba(116, 51, 146, 0.25);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.open-knowledge-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 20px rgba(116, 51, 146, 0.35);
}

/* Domain List Button Styles */
.domain-list li {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  padding: 8px;
  background: #f8f9fa;
  border-radius: 4px;
}

.domain-name {
  flex: 1;
  font-weight: 500;
  color: #495057;
}

.edit-system-role-btn {
  background: #9ca3af;
  color: #6b7280;
  border: none;
  padding: 4px 8px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.8em;
  transition: all 0.2s ease;
}

.edit-system-role-btn:hover {
  background: #17a2b8;
  color: white;
}

.delete-domain-btn {
  color: black;
  border: none;
  padding: 4px 8px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.8em;
  transition: background-color 0.2s ease;
  transition: color 0.2s ease;
  order: -1;
}

.delete-domain-btn:hover {
  background: #c82333;
  color: white;
}

.rag-domain-detail-area {
  background: #f0f0f0;
  padding: 8px;
  border-radius: 4px;
}

.color-palette {
  display: flex;
  gap: 4px;
  margin: 8px 0;
}

.color-swatch {
  width: 20px;
  height: 20px;
  border: 1px solid #ccc;
  border-radius: 4px;
  cursor: pointer;
}

.color-swatch.selected {
  border: 2px solid #000;
}

/* File Input Tooltip Styles */
.file-input-tooltip {
  position: relative;
  display: inline-block;
  margin-left: 4px;
  cursor: help;
  color: var(--color-primary);
  font-weight: bold;
  font-size: 0.9em;
}

.file-input-tooltip .tooltip-text {
  visibility: hidden;
  width: 300px;
  background-color: #333;
  color: #fff;
  text-align: left;
  border-radius: 6px;
  padding: 8px;
  position: absolute;
  z-index: 1000;
  bottom: 125%;
  left: 50%;
  margin-left: -150px;
  opacity: 0;
  transition: opacity 0.3s;
  font-size: 0.8em;
  line-height: 1.4;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.file-input-tooltip .tooltip-text::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  margin-left: -5px;
  border-width: 5px;
  border-style: solid;
  border-color: #333 transparent transparent transparent;
}

.file-input-tooltip:hover .tooltip-text {
  visibility: visible;
  opacity: 1;
}

/* 統一モーダル CSS変数 - Moved to main :root block above */

/* Health modal styles */
.health-modal-backdrop {
  position: fixed;          /* ← これが肝 */
  inset: 0;                 /* top/left/right/bottom: 0 */
  z-index: 2000;            /* settings(1000) や他オーバーレイより前に */
  background: rgba(0,0,0,.45);
  display: flex;            /* 中央寄せ */
  align-items: center;
  justify-content: center;

  opacity: 0;
  transition: opacity var(--modal-exit-ms) ease;
}
.health-modal-backdrop.show { opacity: 1; }
.health-modal-backdrop.closing { opacity: 0; }

/* モーダル本体：入場は従来どおり。退場は keyframes を使う */
.health-modal {
  position: relative;       /* 任意：内部のabsolute用 */
  width: min(92vw, 640px);
  max-height: 80vh;
  overflow: auto;

  background: #fff;
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0,0,0,.2);

  transform: scale(.98);
  opacity: 0;
  filter: blur(0);
  transform-origin: center;
  will-change: transform, opacity, filter;
  transition: transform 160ms ease, opacity 160ms ease;
}
.health-modal-backdrop.show .health-modal {
  transform: scale(1);
  opacity: 1;
}

/* 退場アニメーション：少しだけ拡大しつつ透明＆ぼかし */
@keyframes modal-exit {
  to {
    transform: scale(1.06);
    opacity: 0;
    filter: blur(8px);
  }
}
.health-modal.closing {
  animation: modal-exit var(--modal-exit-ms) cubic-bezier(.2,.7,.3,1) forwards;
}

/* アクセシビリティ：モーション削減指定のときはアニメ無効 */
@media (prefers-reduced-motion: reduce) {
  .health-modal, .health-modal-backdrop {
    transition: none !important;
    animation: none !important;
  }
}
.health-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  background: linear-gradient(90deg, var(--color-gradient-start), var(--color-gradient-end));
  color: #fff;
}
.health-modal-header h3 { margin: 0; font-size: 16px; }
.health-modal-close {
  background: transparent;
  color: #fff;
  border: none;
  font-size: 20px;
  cursor: pointer;
}
.health-modal-body { padding: 12px; }
.health-process { list-style: none; padding: 0; margin: 8px 0 0; }
.health-process li { display: flex; justify-content: space-between; padding: 4px 0; border-bottom: 1px dashed #e6eefc; }
.health-process .val.ok { color: #16a34a; font-weight: 600; }
.health-process .val.pending { color: #b45309; font-weight: 600; }

/* BaseModal 統一スタイル */
.base-modal-open {
  overflow: hidden !important;
}

.base-modal-root {
  position: fixed;
  inset: 0;
  z-index: var(--base-modal-z-index);
  pointer-events: none;
}

.base-modal-backdrop {
  position: fixed;
  inset: 0;
  background: var(--base-modal-backdrop);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity var(--base-modal-exit-ms) ease;
  pointer-events: auto;
}

.base-modal-backdrop.show {
  opacity: 1;
}

.base-modal-backdrop.closing {
  opacity: 0;
}

.base-modal {
  position: relative;
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: #fff;
  border-radius: var(--base-modal-border-radius);
  box-shadow: var(--base-modal-shadow);
  transform: scale(.98);
  opacity: 0;
  filter: blur(0);
  transform-origin: center;
  will-change: transform, opacity, filter;
  transition: transform 160ms ease, opacity 160ms ease;
}

  /* BaseModal typography */
  .base-modal-body h1,
  .base-modal-body h2,
  .base-modal-body h3,
  .base-modal-body h4,
  .base-modal-body h5,
  .base-modal-body h6 {
    font-weight: 700;
    color: var(--color-text);
    line-height: 1.35;
    font-family: sans-serif;
  }

  .base-modal-body h3,
  .base-modal-body h4,
  .base-modal-body h5,
  .base-modal-body h6 {
    margin-top: 10pt;
    margin-bottom: 10pt;
  }

  .base-modal-body h2 {
    font-size: 14pt;
    font-weight: 500;
  }
  .base-modal-body h3 {
    font-size: 13pt;
    font-weight: 500;
  }
  .base-modal-body h4 {
    font-size: 12pt;
    font-weight: 500;
  }
  .base-modal-body h5 {
    font-size: 11pt;
    font-weight: 500;
  }
  .base-modal-body h6 {
    font-size: 10.5pt;
    font-weight: 500;
  }

  .base-modal-body p {
    margin: 0 0 10px;
    color: var(--color-text-secondary);
    line-height: 1.6;
    font-size: 10.5pt;
    font-family: serif;
  }
  .base-modal .base-modal-comment {
    font-size: 10pt;
    font-family: serif;
    line-height: 1.6;
  }

/* サイズバリエーション */
.base-modal-backdrop[data-size="small"] .base-modal {
  width: var(--base-modal-small);
}

.base-modal-backdrop[data-size="medium"] .base-modal {
  width: var(--base-modal-medium);
}

.base-modal-backdrop[data-size="large"] .base-modal {
  width: var(--base-modal-large);
  height: 80vh;
  max-height: 80vh;
  min-height: 80vh;
}

.base-modal-backdrop[data-size="large"] .base-modal-body {
  max-height: 80vh;
}

.base-modal-backdrop[data-size="fullscreen"] .base-modal {
  width: var(--base-modal-fullscreen);
  height: 100vh;
  max-height: none;
  border-radius: 0;
}

.base-modal-backdrop.show .base-modal {
  transform: scale(1);
  opacity: 1;
}

/* 退場アニメーション */
@keyframes base-modal-exit {
  to {
    transform: scale(1.06);
    opacity: 0;
    filter: blur(8px);
  }
}

.base-modal.closing {
  animation: base-modal-exit var(--base-modal-exit-ms) cubic-bezier(.2,.7,.3,1) forwards;
}

/* ロック状態の視覚表現 */
.base-modal-backdrop[data-locked="true"] {
  cursor: not-allowed;
}

.base-modal-backdrop[data-locked="true"] .base-modal {
  box-shadow: var(--base-modal-shadow), 0 20px 40px rgba(0, 0, 0, 0.18);
}

/* モーダルパーツ */
.base-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  background: var(--base-modal-header-bg);
  color: #fff;
  border-top-left-radius: var(--base-modal-border-radius);
  border-top-right-radius: var(--base-modal-border-radius);
}

.base-modal-header h3 {
  margin: 0;
  font-size: 16px;
}

.base-modal-close {
  background: transparent;
  color: #fff;
  border: none;
  font-size: 20px;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  transition: background-color 0.2s ease;
}

.base-modal-close:hover {
  background: rgba(255, 255, 255, 0.1);
}

.base-modal-close:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

.base-modal-body {
  padding: 12px;
  flex: 1;
  overflow: auto;
  max-height: calc(90vh - 120px); /* Account for header and potential footer */
}

.base-modal-footer {
  display: none;
  padding: 10px 12px;
  border-top: 1px solid #e5e7eb;
  background: #f9fafb;
  justify-content: flex-end;
  gap: 8px;
  border-bottom-left-radius: var(--base-modal-border-radius);
  border-bottom-right-radius: var(--base-modal-border-radius);
}

/* アクセシビリティ：モーション削減指定のときはアニメ無効 */
@media (prefers-reduced-motion: reduce) {
  .base-modal, .base-modal-backdrop {
    transition: none !important;
    animation: none !important;
  }
}


/* Streaming fade-in/blur effect for newly appended content */
.bubble .bubble-content {
  transition: opacity 0.2s ease-out, filter 0.2s ease-out;
}
.bubble .bubble-content.blurred {
  opacity: 0.6;
  filter: blur(2px);
}

@media (prefers-reduced-motion: reduce) {
  .bubble .bubble-content { transition: none; }
}

/* Per-flush chunk animation: only newly appended nodes animate */
.bubble .bubble-content .chunk {
  opacity: 0;
  filter: blur(8px);
  transition: opacity 0.5s ease-out, filter 0.5s ease-out;
}
.bubble .bubble-content .chunk.visible {
  opacity: 1;
  filter: blur(0);
}

/* Chat completion light effect */

.chat-send {
  transition: all 0.3s ease;
}

.chat-send.light-received {
  background: linear-gradient(90deg, #6a11cb, #2575fc);
  box-shadow: 0 0 8px rgba(37, 117, 252, 0.4);
  animation: send-button-glow 1s ease-out forwards;
}

@keyframes send-button-glow {
  0% {
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  }
  50% {
    box-shadow: 0 0 8px rgba(37, 117, 252, 0.4), 0 2px 4px rgba(0, 0, 0, 0.1);
  }
  100% {
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  }
}

/* Model change effect for badge */
.model-badge.model-changed {
  animation: model-change-blink 2s ease-in-out;
}

@keyframes model-change-blink {
  0%, 100% { 
    background-color: #e5f3ff;
    color: #1a73e8;
  }
  25%, 75% { 
    background-color: #4f46e5;
    color: white;
  }
  50% {
    background-color: #7c3aed;
    color: white;
  }
}

/* Thread unread notification blink effect */
@keyframes blink {
  0%, 50% { 
    opacity: 1;
    border-color: #8ab4f8;
  }
  25%, 75% { 
    opacity: 0.7;
    border-color: #d32f2f;
    box-shadow: 0 0 8px rgba(211, 47, 47, 0.3);
  }
}

/* LogViewerModal styles */
.log-viewer-container {
  display: flex;
  flex-direction: column;
  height: 70vh;
  max-height: 600px;
  min-height: 400px;
}

.log-status {
  padding: 12px;
  border-bottom: 1px solid #e1e5e9;
  background: #f8f9fa;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-radius: 4px 4px 0 0;
}

.log-status.status-running {
  background: #fff3cd;
  border-color: #ffeaa7;
}

.log-status.status-success {
  background: #d4edda;
  border-color: #c3e6cb;
}

.log-status.status-error {
  background: #f8d7da;
  border-color: #f5c6cb;
}

.status-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
}

.status-indicator svg {
  width: 16px;
  height: 16px;
}

.session-id {
  font-size: 0.875rem;
  color: #6c757d;
  font-family: monospace;
}

.log-content-wrapper {
  flex: 1;
  overflow: hidden;
  border: 1px solid #e1e5e9;
  border-radius: 0 0 4px 4px;
}

.log-content {
  height: 100%;
  overflow-y: auto;
  padding: 12px;
  background: #fff;
  font-family: 'Courier New', monospace;
  font-size: 13px;
  line-height: 1.4;
}

.log-line {
  margin-bottom: 4px;
  padding: 2px 4px;
  border-radius: 2px;
  word-wrap: break-word;
}

.log-line.empty {
  text-align: center;
  color: #6c757d;
  font-style: italic;
  padding: 20px;
}

.log-line.error {
  background: #fff5f5;
  color: #dc3545;
  border-left: 3px solid #dc3545;
  padding-left: 8px;
}

.log-line.warning {
  background: #fffbf0;
  color: #ffc107;
  border-left: 3px solid #ffc107;
  padding-left: 8px;
}

.log-line.success {
  background: #f0fff4;
  color: #28a745;
  border-left: 3px solid #28a745;
  padding-left: 8px;
  font-weight: 500;
}

.log-line.status {
  background: #f8f9fa;
  color: #495057;
  border-left: 3px solid #6c757d;
  padding-left: 8px;
  font-weight: 500;
}

.log-line.info {
  color: #495057;
}

.log-actions {
  padding: 12px;
  border-top: 1px solid #e1e5e9;
  background: #f8f9fa;
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.log-actions .btn {
  padding: 6px 12px;
  border: 1px solid #ccc;
  border-radius: 4px;
  background: #fff;
  cursor: pointer;
  font-size: 0.875rem;
}

.log-actions .btn:hover {
  background: #f8f9fa;
}

.log-actions .btn.btn-primary {
  background: #007bff;
  border-color: #007bff;
  color: white;
}

.log-actions .btn.btn-primary:hover {
  background: #0056b3;
  border-color: #004085;
}

/* Admin console styles */
.admin-console,
.role-console {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.admin-tenant-only[hidden] {
  display: none !important;
}

.admin-console-message,
.role-console-message {
  padding: 10px 12px;
  border-radius: 6px;
  background: #f5f5f5;
  font-size: 14px;
}

.admin-console-message.success,
.role-console-message.success {
  background: #e5f5ec;
  color: #1a7f37;
}

.admin-console-message.error,
.role-console-message.error {
  background: #fdecea;
  color: #b3261e;
}

.admin-console-body,
.role-console-body {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 16px;
}

.admin-section {
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  padding: 16px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.admin-section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.admin-section-header h3,
.admin-section-header h5 {
  margin: 0;
  font-size: 16px;
}

.admin-section-header button {
  border: none;
  background: #5e318f;
  color: #fff;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
}

.admin-section-header button:hover {
  background: #4e2976;
}

.admin-group-create-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
  padding: 12px;
  background: #faf8ff;
  border: 1px solid #e3d9ff;
  border-radius: 6px;
}

.role-section-header h3 {
  margin: 0;
  font-size: 16px;
}

.role-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.role-list-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  background: #fafafa;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}

.role-list-item:hover {
  background: #f0e9ff;
  border-color: #d3c2ff;
}

.role-list-item.active {
  background: #ebe1ff;
  border-color: #5e318f;
  color: #2c1160;
}

.role-chip {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  background: #ece9ff;
  color: #463073;
}

.role-chip--system {
  background: #eef2ff;
  color: #314585;
}

.role-detail {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.role-detail-header {
  display: flex;
  align-items: center;
  gap: 12px;
}

.role-detail-header h3 {
  margin: 0;
  font-size: 18px;
}

.role-detail-form label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
}

.role-detail-form textarea {
  border: 1px solid #d5c9ff;
  border-radius: 6px;
  padding: 8px;
  font-size: 13px;
  resize: vertical;
}

.role-permission-section h4 {
  margin: 0 0 6px;
  font-size: 14px;
}

.role-permission-list {
  display: grid;
  gap: 6px;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
}

.role-permission-list label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  padding: 4px 6px;
  border-radius: 4px;
  transition: background 0.2s;
}

.role-permission-list label:hover {
  background: #f5f1ff;
}

.role-permission-list input[type="checkbox"] {
  accent-color: #5e318f;
}

.role-form-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.role-form-actions button {
  border: none;
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 13px;
  cursor: pointer;
  font-weight: 600;
}

.role-save,
.role-create-save {
  background: #5e318f;
  color: #fff;
}

.role-save:hover,
.role-create-save:hover {
  background: #4e2976;
}

.role-delete {
  background: #fff5f5;
  color: #b3261e;
  border: 1px solid #f3c5c5;
}

.role-delete:hover {
  background: #f8e1e1;
}

.role-create-cancel {
  background: #fff;
  color: #333;
  border: 1px solid #c9c9c9;
}

.role-create-cancel:hover {
  background: #f2f2f2;
}

.role-create-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 12px;
  padding: 12px;
  background: #faf8ff;
  border: 1px solid #e3d9ff;
  border-radius: 6px;
}

.role-create-fields {
  display: grid;
  gap: 8px;
}

.role-create-fields input[type="text"],
.role-create-fields textarea {
  border: 1px solid #d5c9ff;
  border-radius: 6px;
  padding: 6px 8px;
  font-size: 13px;
}

.role-note {
  margin: 0;
  font-size: 12px;
  color: #666;
}

.role-loading {
  text-align: center;
  font-size: 14px;
  color: #555;
}

.role-empty,
.role-empty-permissions {
  font-size: 13px;
  color: #666;
}
.admin-group-create-form label {
  display: flex;
  flex-direction: column;
  font-size: 13px;
  color: #333;
}

.admin-group-create-scope {
  border: 1px solid #d8cfff;
  border-radius: 6px;
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.admin-group-create-scope legend {
  font-size: 12px;
  font-weight: 600;
  color: #5e318f;
  margin-bottom: 4px;
}

.admin-group-create-scope label {
  flex-direction: row;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: #444;
}

.admin-group-scope-target {
  font-size: 12px;
  color: #666;
}

.admin-group-create-form input,
.admin-group-create-form textarea,
.admin-group-detail input,
.admin-group-detail textarea,
.admin-group-detail select,
.admin-users select {
  margin-top: 4px;
  padding: 6px 8px;
  border-radius: 6px;
  border: 1px solid #d0d0d0;
  font-size: 14px;
  background: #fff;
}

.admin-form-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.admin-form-actions .admin-save,
.admin-form-actions .admin-add {
  background: #5e318f;
  color: #fff;
  border: none;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
}

.admin-form-actions .admin-cancel {
  background: transparent;
  color: #5e318f;
  border: 1px solid #5e318f;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
}

.admin-group-items {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.admin-group-list-wrapper {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.admin-group-list-heading {
  font-size: 14px;
  font-weight: 600;
  color: #4e2976;
}

.admin-group-item {
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  padding: 10px;
  background: #fff;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.admin-group-item.selected {
  border-color: #5e318f;
  box-shadow: 0 0 0 2px rgba(94, 49, 143, 0.15);
}

.admin-group-item-main {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
}

.admin-group-tags {
  display: flex;
  gap: 4px;
  margin-left: auto;
}

.admin-group-meta {
  font-size: 12px;
  color: #666;
  display: flex;
  gap: 12px;
}

.admin-group-actions {
  display: flex;
  gap: 8px;
}

.admin-group-actions button,
.admin-members-table .admin-member-remove {
  border: none;
  background: #f0f0f0;
  color: #333;
  border-radius: 4px;
  padding: 4px 10px;
  cursor: pointer;
  font-size: 12px;
}

.admin-group-actions button:hover,
.admin-members-table .admin-member-remove:hover {
  background: #e0e0e0;
}

.admin-tenant-section {
  margin-bottom: 12px;
}

.admin-tenant-items {
  list-style: none;
  margin: 0 0 8px 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.admin-tenant-item {
  padding: 8px 10px;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  background: #faf8ff;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
}

.admin-tenant-item:hover {
  border-color: #5e318f;
}

.admin-tenant-item.selected {
  border-color: #5e318f;
  box-shadow: 0 0 0 2px rgba(94, 49, 143, 0.15);
}

.admin-tenant-name {
  font-weight: 600;
}

.admin-tenant-meta {
  color: #666;
  font-size: 12px;
}

.admin-group-chip {
  display: inline-flex;
  align-items: center;
  padding: 2px 6px;
  font-size: 11px;
  border-radius: 999px;
  background: #ebe1ff;
  color: #4c2f74;
  text-transform: uppercase;
}

.admin-group-chip--tenant {
  background: #f1f8ff;
  color: #2f54eb;
}

.admin-group-chip--system {
  background: #ffeceb;
  color: #ab2f26;
}

.admin-group-context {
  display: flex;
  gap: 8px;
  font-size: 12px;
  color: #555;
}

.admin-group-context-label {
  background: #f5f1ff;
  border-radius: 999px;
  padding: 2px 8px;
}

.admin-group-detail-wrapper {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.admin-group-description {
  margin: 0;
  color: #444;
  font-size: 14px;
}

.admin-group-members {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.admin-role-checkboxes {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 8px;
}

.admin-role-select {
  display: flex;
}

.admin-role-select select {
  width: 100%;
  min-height: 120px;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
}

.admin-table th,
.admin-table td {
  border: 1px solid #e0e0e0;
  padding: 8px;
  text-align: left;
  font-size: 13px;
}

.admin-table th {
  background: #f8f8f8;
}

.admin-empty {
  margin: 0;
  color: #777;
  font-size: 13px;
}

.admin-users {
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  padding: 16px;
}

.admin-users-table {
  overflow-x: auto;
}

.admin-user-chip {
  display: inline-flex;
  align-items: center;
  padding: 2px 6px;
  border-radius: 999px;
  background: #eef2ff;
  color: #3c4aad;
  font-size: 11px;
  margin-right: 4px;
}

.admin-user-chip.muted {
  background: #f0f0f0;
  color: #666;
}

.admin-user-chip.role {
  background: #e6f4ff;
  color: #245a9d;
}

.admin-user-chip.perm {
  background: #f0f5ff;
  color: #2f54eb;
  margin-bottom: 2px;
}

.admin-user-permissions {
  margin-top: 4px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.admin-user-permissions[hidden] {
  display: none !important;
}

.admin-permission-toggle {
  border: none;
  background: transparent;
  color: #5e318f;
  cursor: pointer;
  font-size: 12px;
  margin-top: 4px;
  padding: 0;
}

.admin-permission-toggle:hover {
  text-decoration: underline;
}

.admin-loading {
  align-self: center;
  padding: 8px 12px;
  border-radius: 6px;
  background: rgba(94, 49, 143, 0.12);
  color: #38215c;
  font-weight: 600;
}

.admin-user-group-editor {
  margin-top: 8px;
  display: flex;
  gap: 8px;
  align-items: flex-start;
  flex-wrap: wrap;
}

.admin-user-groups-label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: #444;
  min-width: 180px;
}

.admin-user-groups-label select {
  min-width: 200px;
}

.admin-user-groups-display {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.admin-user-groups-heading {
  font-size: 12px;
  color: #666;
  font-weight: 600;
}

.admin-user-groups-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.admin-user-group-editor select {
  min-width: 200px;
  font-size: 13px;
}

.admin-user-group-editor button {
  border: none;
  background: #5e318f;
  color: #fff;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
}

.admin-user-group-editor button:hover {
  background: #4e2976;
}

.admin-user-delete {
  border: none;
  background: #ffecec;
  color: #a61d24;
  padding: 6px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
}

.admin-user-delete:disabled {
  background: #f2f2f2;
  color: #999;
  cursor: not-allowed;
}

.admin-user-delete:not(:disabled):hover {
  background: #ffd5d5;
}

.admin-console-denied {
  padding: 24px;
  background: #fff8e6;
  border: 1px solid #ffe2a8;
  border-radius: 8px;
  color: #8a5a00;
}

.admin-note {
  font-size: 12px;
  color: #666;
  margin: 4px 0;
}

.tenant-console {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.tenant-console-header h3 {
  margin: 0 0 4px;
  font-size: 18px;
}

.tenant-console-description {
  margin: 0;
  color: #666;
  font-size: 13px;
}

.tenant-console-message {
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 13px;
}

.tenant-console-message.info {
  background: #eef2ff;
  color: #3c4aad;
}

.tenant-console-message.success {
  background: #e6ffed;
  color: #1d7d3e;
}

.tenant-console-message.error {
  background: #ffe6e6;
  color: #a61d24;
}

.tenant-console-message[hidden] {
  display: none !important;
}

.tenant-create-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 12px;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  background: #faf8ff;
}

.tenant-create-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: #333;
}

.tenant-create-form input,
.tenant-create-form textarea {
  padding: 6px 8px;
  border-radius: 6px;
  border: 1px solid #d0d0d0;
  font-size: 14px;
  background: #fff;
}

.tenant-form-actions {
  display: flex;
  justify-content: flex-end;
}

.tenant-create-btn {
  background: #5e318f;
  color: #fff;
  border: none;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
}

.tenant-create-btn:hover {
  background: #4e2976;
}

.tenant-loading {
  align-self: flex-start;
  padding: 6px 10px;
  background: rgba(94, 49, 143, 0.12);
  color: #38215c;
  border-radius: 6px;
  font-size: 12px;
}

.tenant-loading[hidden] {
  display: none !important;
}

.tenant-empty {
  margin: 0;
  font-size: 13px;
  color: #555;
}

.tenant-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.tenant-card {
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  padding: 12px;
  background: #fff;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.tenant-card-header {
  display: flex;
  align-items: center;
  gap: 8px;
}

.tenant-card-header h4 {
  margin: 0;
  font-size: 16px;
}

.tenant-card-description {
  margin: 0;
  font-size: 13px;
  color: #444;
  white-space: pre-wrap;
}

.tenant-description-empty {
  color: #999;
  font-style: italic;
}

.tenant-card-footer {
  display: flex;
  gap: 8px;
}

.tenant-card-footer button {
  border: none;
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 12px;
  cursor: pointer;
  background: #f0f0f0;
  color: #333;
}

.tenant-card-footer button:hover {
  background: #e0e0e0;
}

.tenant-card-footer button.tenant-delete {
  background: #ffecec;
  color: #a61d24;
}

.tenant-card-footer button.tenant-delete:hover {
  background: #ffd5d5;
}

.tenant-chip {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  background: #eef2ff;
  color: #3c4aad;
}

.tenant-chip--system {
  background: #ffecec;
  color: #a61d24;
}

@media (max-width: 1024px) {
  .admin-console-body {
    grid-template-columns: 1fr;
  }
}


.admin-user-groups-options {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 160px;
  overflow-y: auto;
  padding: 4px 0;
}

.admin-user-group-option {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
}

.rag-domain-acl-area {
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 16px;
  background: #fafafa;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.rag-acl-entry {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
}

.rag-acl-entry select {
  min-width: 160px;
  padding: 4px 6px;
  border-radius: 4px;
  border: 1px solid #d0d0d0;
}

.rag-acl-entry--user {
  gap: 8px;
}

.rag-acl-user-add {
  align-self: flex-start;
  border: 1px solid #5e318f;
  background: #fff;
  color: #5e318f;
  border-radius: 6px;
  padding: 4px 12px;
  cursor: pointer;
  font-size: 12px;
}

.rag-acl-user-add:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.rag-acl-remove {
  border: none;
  background: transparent;
  color: #b3261e;
  cursor: pointer;
  font-size: 12px;
}

.rag-acl-remove:disabled {
  opacity: 0.6;
  cursor: default;
}

.domain-acl-editor {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.domain-acl-editor h4 {
  margin: 0;
}

.domain-acl-editor .acl-description {
  font-size: 12px;
  color: #666;
  margin: 0;
}

.rag-acl-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.rag-acl-save {
  border: none;
  background: #5e318f;
  color: #fff;
  padding: 6px 16px;
  border-radius: 6px;
  cursor: pointer;
}

.rag-acl-save:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.rag-acl-message {
  font-size: 12px;
}

.rag-acl-message--success {
  color: #1a7f37;
}

.rag-acl-message--error {
  color: #b3261e;
}

.rag-acl-message--pending {
  color: #5e318f;
}

.rag-acl-message--warning {
  color: #b7791f;
}

.rag-acl-readonly {
  opacity: 0.75;
}

.rag-acl-table {
  width: 100%;
  border-collapse: collapse;
  margin: 8px 0;
}

.rag-acl-table th,
.rag-acl-table td {
  border: 1px solid #dcdcdc;
  padding: 6px;
  text-align: center;
  font-size: 13px;
}

.rag-acl-table th:first-child,
.rag-acl-table td:first-child {
  text-align: left;
  white-space: nowrap;
}

.rag-acl-permission-column,
.rag-acl-permission-cell {
  width: 88px;
  min-width: 88px;
}

.rag-acl-radio,
.rag-acl-checkbox {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
}

.rag-acl-radio input[type="radio"],
.rag-acl-checkbox input[type="checkbox"] {
  margin: 0;
}

.rag-acl-table input[type="radio"][disabled],
.rag-acl-table input[type="checkbox"][disabled] {
  cursor: not-allowed;
}

.rag-acl-owner-row {
  background-color: #f1f3f5;
  color: #5c6b73;
}

.rag-acl-checkbox--locked {
  opacity: 0.6;
}

.rag-acl-info {
  font-size: 12px;
  color: #666;
  margin: 0;
}
