    /* ── Design tokens ── */
    :root {
      --brand:       #008FA3;
      --brand-dark:  #007C8F;
      --brand-light: #EAF7F9;
      --bg:          #F5FAFA;
      --card-bg:     #FFFFFF;
      --border:      #D7E7EA;
      --text:        #222222;
      --sub:         #777777;
      --placeholder: #A0A0A0;
      --icon-weak:   #8ABEC7;
      --success:     #2E7D32;
      --warning:     #B26A00;
      --error:       #C0392B;
      --disabled:    #C7DDE2;
      --active-bg:   #EEF7F8;
      --active-text: #008FA3;
      --sb-border:   #E3EFF1;
      --r-sm: 4px; --r: 8px; --r-md: 10px; --r-lg: 12px;
      --shadow-sm: 0 1px 3px rgba(0,143,163,.06);
      --shadow:    0 2px 10px rgba(0,143,163,.09);
    }

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

    body {
      font-family: "Hiragino Sans","Hiragino Kaku Gothic ProN","Noto Sans JP","Yu Gothic","Meiryo",sans-serif;
      background: var(--bg);
      color: var(--text);
      height: 100vh; height: 100dvh;
      display: flex; flex-direction: column;
      font-size: 14px; line-height: 1.6;
    }

    /* ── Page structure ── */
    .page-body { flex: 1; display: flex; overflow: hidden; }

    /* ── Sidebar ── */
    .sidebar {
      width: 268px;
      background: #fff;
      border-right: 1px solid var(--border);
      display: flex; flex-direction: column;
      flex-shrink: 0; overflow: hidden;
    }

    .sidebar-logo {
      padding: 16px 14px 12px;
      border-bottom: 1px solid var(--sb-border);
      display: flex; align-items: center; gap: 10px;
      text-decoration: none;
    }

    .sidebar-logo-icon {
      width: 34px; height: 34px;
      border-radius: 8px;
      display: flex; align-items: center; justify-content: center;
      flex-shrink: 0; overflow: hidden; position: relative;
    }
    .sidebar-logo-icon::after {
      content: ''; position: absolute; inset: 0;
      background: var(--brand); mix-blend-mode: screen; pointer-events: none;
    }
    .sidebar-logo-icon-img {
      width: 100%; height: 100%; object-fit: contain;
    }

    .sidebar-logo-name {
      font-size: 15px; font-weight: 700; color: var(--brand); letter-spacing: .01em;
    }
    .sidebar-logo-name small {
      display: block; font-size: 10px; font-weight: 400; color: var(--sub); letter-spacing: 0;
    }

    .sidebar-new-btn {
      margin: 10px 10px 6px;
      display: flex; align-items: center; gap: 7px;
      background: var(--brand-light);
      color: var(--brand);
      border: 1px solid var(--border);
      border-radius: var(--r-md);
      padding: 8px 14px;
      font-size: 13px; font-weight: 600;
      cursor: pointer; text-decoration: none;
      transition: background .14s, border-color .14s;
    }
    .sidebar-new-btn:hover { background: #ceedf1; border-color: var(--brand); }

    .sidebar-section-label {
      padding: 10px 16px 5px;
      font-size: 10px; font-weight: 700;
      color: var(--sub); letter-spacing: .07em; text-transform: uppercase;
    }

    .conv-list { flex: 1; overflow-y: auto; padding-bottom: 4px; }

    .conv-item {
      position: relative;
      padding: 8px 10px;
      border-radius: var(--r);
      margin: 1px 6px;
      cursor: default;
      display: flex; align-items: flex-start; gap: 6px;
      transition: background .12s, opacity .12s;
    }
    .conv-item.clickable { cursor: pointer; }
    .conv-item.clickable:hover,
    .conv-item.clickable:focus-within {
      background: #e4f3f6;
      outline: none;
    }
    .conv-item.clickable:hover .conv-title,
    .conv-item.clickable:focus-within .conv-title {
      color: var(--brand);
    }
    .conv-item.clickable:hover .conv-summary,
    .conv-item.clickable:hover .conv-meta,
    .conv-item.clickable:focus-within .conv-summary,
    .conv-item.clickable:focus-within .conv-meta {
      color: var(--brand-dark);
    }
    .conv-item.active {
      background: var(--active-bg);
      border-right: 3px solid var(--brand);
      padding-right: 7px;
    }
    .conv-item.navigating { opacity: .72; }

    .conv-item-body { flex: 1; overflow: hidden; min-width: 0; }
    .conv-hit-area {
      position: absolute;
      inset: 0 34px 0 0;
      z-index: 1;
      border-radius: var(--r);
      text-decoration: none;
    }
    .conv-hit-area:focus-visible {
      outline: 3px solid rgba(0,143,163,.18);
      outline-offset: -2px;
    }
    .conv-item.editing .conv-hit-area { display: none; }
    .conv-link {
      display: block;
      color: inherit;
      text-decoration: none;
      border-radius: var(--r);
      outline: none;
    }

    /* ── Thread search ── */
    .thread-search-row { padding: 4px 10px 6px; }
    .thread-search-input {
      width: 100%; padding: 5px 10px;
      border: 1px solid var(--border); border-radius: var(--r-sm);
      font-size: 12px; font-family: inherit; color: var(--text);
      background: #fff; outline: none;
    }
    .thread-search-input:focus { border-color: var(--brand); }

    /* ── Thread three-dot menu ── */
    .thread-menu-wrapper { position: relative; flex-shrink: 0; z-index: 3; }
    .thread-dropdown {
      position: absolute; right: 0; top: calc(100% + 2px);
      background: #fff; border: 1px solid var(--border);
      border-radius: var(--r); box-shadow: var(--shadow);
      min-width: 124px; z-index: 200; overflow: hidden;
    }
    .thread-dropdown.hidden { display: none; }
    .thread-dropdown-item {
      display: flex; align-items: center; gap: 6px;
      width: 100%; padding: 7px 12px;
      font-size: 12px; font-family: inherit;
      background: none; border: none; cursor: pointer;
      color: var(--text); text-align: left;
    }
    .thread-dropdown-item:hover { background: var(--brand-light); color: var(--brand); }
    .thread-dropdown-item.danger { color: var(--error); }
    .thread-dropdown-item.danger:hover { background: #fef0f0; color: var(--error); }

    /* ── Thread rename form ── */
    .thread-rename-form { margin-top: 2px; }
    .thread-rename-input {
      width: 100%; border: 1px solid var(--border); border-radius: var(--r-sm);
      padding: 3px 7px; font-size: 12px; font-family: inherit;
      color: var(--text); background: #fff; outline: none;
    }
    .thread-rename-input:focus { border-color: var(--brand); }
    .thread-rename-save {
      padding: 3px 10px; background: var(--brand); color: #fff;
      border: none; border-radius: var(--r-sm);
      font-size: 11px; cursor: pointer; font-family: inherit;
    }
    .thread-rename-cancel {
      padding: 3px 8px; border: 1px solid var(--border);
      background: #fff; border-radius: var(--r-sm);
      font-size: 11px; cursor: pointer; font-family: inherit; color: var(--text);
    }

    .conv-title {
      font-size: 13px; font-weight: 500;
      white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
      color: var(--text);
    }
    .conv-item.active .conv-title { color: var(--active-text); font-weight: 600; }

    .conv-summary {
      font-size: 11px; color: var(--sub);
      white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 1px;
    }
    .conv-meta { font-size: 10px; color: #bbb; margin-top: 1px; }

    /* ── Sidebar bottom / user area ── */
    .sidebar-bottom { border-top: 1px solid var(--sb-border); padding: 6px; }

    .sidebar-nav-link {
      display: flex; align-items: center; gap: 8px;
      padding: 8px 10px;
      border-radius: var(--r);
      font-size: 13px; color: var(--sub);
      text-decoration: none;
      transition: background .12s, color .12s;
      cursor: pointer; background: none; border: none; width: 100%; text-align: left;
    }
    .sidebar-nav-link:hover { background: var(--brand-light); color: var(--brand); }

    .sidebar-user {
      padding: 8px 10px 10px;
      border-top: 1px solid var(--sb-border);
      display: flex; align-items: center; gap: 9px;
      position: relative; cursor: pointer;
    }
    .sidebar-user:hover .user-avatar { background: var(--brand-dark); }

    .user-avatar {
      width: 30px; height: 30px; border-radius: 50%;
      background: var(--brand);
      color: #fff; display: flex; align-items: center; justify-content: center;
      font-size: 12px; font-weight: 700; flex-shrink: 0;
      transition: background .15s;
    }

    .user-info { flex: 1; overflow: hidden; }
    .user-name  { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .user-email { font-size: 10px; color: var(--sub); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

    .user-menu-btn {
      background: none; border: none; cursor: pointer; color: var(--sub);
      padding: 3px 5px; border-radius: var(--r-sm); font-size: 15px; line-height: 1;
    }
    .user-menu-btn:hover { background: var(--brand-light); color: var(--brand); }

    /* Account dropdown */
    .account-menu {
      position: absolute;
      bottom: calc(100% + 2px); left: 6px; right: 6px;
      background: #fff;
      border: 1px solid var(--border);
      border-radius: var(--r-lg);
      box-shadow: 0 4px 20px rgba(0,143,163,.14);
      padding: 6px; z-index: 100; display: none;
    }
    .account-menu.show { display: block; }

    .acct-menu-item {
      display: flex; align-items: center; gap: 8px;
      padding: 9px 12px;
      border-radius: var(--r);
      font-size: 13px; color: var(--text);
      text-decoration: none; cursor: pointer;
      background: none; border: none; width: 100%; text-align: left;
      transition: background .12s;
    }
    .acct-menu-item:hover { background: var(--brand-light); color: var(--brand); }
    .acct-menu-item.danger { color: var(--error); }
    .acct-menu-item.danger:hover { background: #fef0f0; }
    .acct-menu-divider { height: 1px; background: var(--border); margin: 4px 0; }

    /* ── Chat area ── */
    .chat-area { flex: 1; display: flex; flex-direction: column; overflow: hidden; background: var(--bg); }

    .messages {
      flex: 1; overflow-y: auto;
      padding: 28px max(20px, calc(50% - 450px));
      display: flex; flex-direction: column; gap: 16px;
    }

    /* User bubble */
    .bubble.user {
      background: var(--brand); color: #fff;
      align-self: flex-end; max-width: 66%;
      padding: 11px 16px;
      border-radius: var(--r-lg) var(--r-lg) var(--r-sm) var(--r-lg);
      font-size: 14px; line-height: 1.65;
      word-break: break-word; white-space: pre-wrap;
    }

    /* AI answer card */
    .bubble.assistant {
      background: var(--card-bg);
      border: 1px solid var(--border);
      border-radius: var(--r-sm) var(--r-lg) var(--r-lg) var(--r-lg);
      box-shadow: var(--shadow-sm);
      padding: 16px 20px;
      align-self: flex-start; max-width: 100%;
      font-size: 14px; line-height: 1.78; color: var(--text);
      word-break: break-word;
    }

    /* Thinking bubble */
    .bubble.thinking {
      display: flex; align-items: center; gap: 10px;
      align-self: flex-start;
      padding: 6px 2px;
      font-size: 13px; color: var(--sub); max-width: 80%;
    }

    .thinking-spinner {
      width: 20px; height: 20px;
      border: 2px solid var(--brand-light);
      border-top-color: var(--brand);
      border-radius: 50%;
      animation: spin .9s linear infinite;
      flex-shrink: 0;
    }

    @keyframes spin { to { transform: rotate(360deg); } }

    .thinking-status { font-size: 13px; color: var(--sub); }

    /* Error bubble */
    .bubble.error {
      background: #fff5f5; border: 1px solid #fcc; border-radius: var(--r);
      padding: 12px 16px; color: var(--error); font-size: 13px;
      align-self: flex-start; max-width: 80%;
    }

    /* Answer content */
    .answer-text { display: block; white-space: pre-wrap; }

    /* References */
    .references {
      margin-top: 12px; padding-top: 12px;
      border-top: 1px solid var(--border); font-size: 12px;
    }
    .references-label {
      color: var(--sub); margin-bottom: 6px;
      font-size: 10px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase;
    }
    .reference-item {
      display: inline-flex; align-items: center; gap: 4px;
      padding: 3px 9px; border-radius: 999px;
      background: var(--brand-light); color: var(--brand);
      font-size: 11px; text-decoration: none;
      margin: 2px 4px 2px 0;
      border: 1px solid var(--border);
      max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
      transition: background .12s;
    }
    .reference-item:hover { background: #bde8ee; }
    .reference-item.ref-active { background: var(--brand); color: #fff; border-color: var(--brand-dark); }

    .ref-link {
      color: var(--brand); text-decoration: none;
      font-size: .78em; vertical-align: super;
      border-radius: 999px; padding: 0 2px;
    }
    .ref-link:hover, .ref-link.ref-active { text-decoration: underline; background: var(--brand-light); }

    /* Feedback row */
    .feedback-row {
      display: flex; align-items: center; gap: 8px;
      margin-top: 12px; padding-top: 12px;
      border-top: 1px solid var(--border);
      flex-wrap: wrap;
    }
    .feedback-label { font-size: 11px; color: var(--sub); flex-shrink: 0; }

    .feedback-btn {
      display: inline-flex; align-items: center; gap: 5px;
      padding: 4px 13px; border-radius: 999px;
      border: 1px solid var(--border);
      background: #fff; color: var(--sub);
      font-size: 12px; cursor: pointer;
      transition: all .14s;
    }
    .feedback-btn:hover { border-color: var(--brand); color: var(--brand); background: var(--brand-light); }
    .feedback-btn.ok.selected  { background: #e6f4ea; border-color: var(--success); color: var(--success); }
    .feedback-btn.ng.selected  { background: #fef0f0; border-color: var(--error); color: var(--error); }
    .feedback-thanks { font-size: 11px; color: var(--success); }
    .feedback-error  { font-size: 11px; color: var(--error); }

    /* NG Reason Modal */
    .modal-overlay {
      position: fixed; inset: 0;
      background: rgba(0,0,0,.38);
      backdrop-filter: blur(3px);
      display: flex; align-items: center; justify-content: center;
      z-index: 200;
    }
    .modal-card {
      background: #fff; border-radius: var(--r-lg);
      box-shadow: 0 8px 32px rgba(0,0,0,.18);
      padding: 24px; width: 420px; max-width: calc(100vw - 32px);
    }
    .modal-title { font-size: 15px; font-weight: 700; margin-bottom: 16px; }
    .modal-reason-grid { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
    .modal-reason-btn {
      padding: 6px 13px; border-radius: 999px;
      border: 1px solid var(--border); background: #fff;
      font-size: 12px; color: var(--text); cursor: pointer;
      transition: all .12s; font-family: inherit;
    }
    .modal-reason-btn:hover, .modal-reason-btn.selected {
      background: #fef0f0; border-color: var(--error); color: var(--error);
    }
    .modal-actions { display: flex; gap: 8px; justify-content: flex-end; }

    .btn-cancel {
      padding: 8px 18px; border-radius: var(--r);
      border: 1px solid var(--border); background: #fff;
      color: var(--sub); font-size: 13px; cursor: pointer; font-family: inherit;
    }
    .btn-cancel:hover { background: var(--bg); }

    .btn-ng-submit {
      padding: 8px 18px; border-radius: var(--r);
      border: none; background: var(--error); color: #fff;
      font-size: 13px; cursor: pointer; font-family: inherit;
    }
    .btn-ng-submit:hover { background: #a93226; }
    .btn-ng-submit:disabled { background: var(--disabled); cursor: not-allowed; }

    /* Meta badges */
    .meta-row { display: flex; gap: 6px; flex-wrap: wrap; align-self: flex-start; margin-top: -8px; }
    .badge { font-size: 11px; padding: 3px 9px; border-radius: 999px; }
    .badge-safe    { background: #e6f4ea; color: var(--success); }
    .badge-caution { background: #fff3e0; color: var(--warning); }
    .badge-budget  { background: var(--brand-light); color: var(--brand); }

    /* Tool trace */
    details.tool-trace { margin-top: 10px; font-size: 12px; }
    details.tool-trace summary {
      cursor: pointer; color: var(--sub); font-size: 11px; padding: 4px 0; user-select: none;
    }
    .trace-entry { padding: 3px 8px; border-bottom: 1px solid #f0f8fa; color: #666; }

    /* Download card */
    .download-card {
      display: flex; align-items: center; gap: 12px;
      margin-top: 12px; padding: 11px 14px;
      background: var(--bg); border: 1px solid var(--border); border-radius: var(--r);
    }
    .download-icon {
      width: 36px; height: 36px; border-radius: var(--r);
      background: var(--brand-light);
      display: flex; align-items: center; justify-content: center;
      color: var(--brand); font-size: 18px; flex-shrink: 0;
    }
    .download-info { flex: 1; }
    .download-name { font-size: 13px; font-weight: 500; }
    .download-meta { font-size: 11px; color: var(--sub); margin-top: 2px; }
    .btn-dl {
      padding: 5px 14px; border-radius: var(--r);
      background: var(--brand); color: #fff; border: none;
      font-size: 12px; cursor: pointer; text-decoration: none;
      transition: background .14s; flex-shrink: 0; font-family: inherit;
    }
    .btn-dl:hover { background: var(--brand-dark); }

    /* Input area */
    .input-area { padding: 12px max(20px, calc(50% - 450px)) 20px; background: transparent; }

    .input-card {
      background: #fff; border: 1px solid var(--border); border-radius: var(--r-lg);
      box-shadow: var(--shadow);
      padding: 10px 14px;
      display: flex; gap: 10px; align-items: flex-end;
    }
    .input-card textarea {
      flex: 1; resize: none; border: none; outline: none;
      font-size: 14px; font-family: inherit; line-height: 1.6;
      max-height: 160px; overflow-y: auto;
      background: transparent; color: var(--text);
    }
    .input-card textarea::placeholder { color: var(--placeholder); }

    #send-btn {
      width: 38px; height: 38px; border-radius: 50%;
      background: var(--brand); color: #fff; border: none;
      cursor: pointer;
      display: flex; align-items: center; justify-content: center;
      flex-shrink: 0; transition: background .14s; font-size: 16px;
    }
    #send-btn:hover { background: var(--brand-dark); }
    #send-btn:disabled { background: var(--disabled); cursor: not-allowed; }

    /* Empty state */
    .empty-state { text-align: center; color: var(--sub); font-size: 14px; }
    .new-chat-messages { justify-content: center; }
    .new-chat-prompt { margin: auto; text-align: center; }
    .new-chat-prompt .logo-mark {
      width: 80px; height: 80px;
      display: flex; align-items: center; justify-content: center;
      margin: 0 auto 20px; position: relative; overflow: hidden;
    }
    .new-chat-prompt .logo-mark::after {
      content: ''; position: absolute; inset: 0;
      background: var(--brand); mix-blend-mode: screen; pointer-events: none;
    }
    .new-chat-prompt .logo-mark-img {
      width: 100%; height: 100%; object-fit: contain;
    }
    .new-chat-prompt h1 { font-size: 24px; font-weight: 700; color: var(--text); margin-bottom: 8px; }
    .new-chat-prompt p  { font-size: 14px; color: var(--sub); }

    /* ── Auth pages ── */
    .auth-page {
      flex: 1; display: flex;
      align-items: center; justify-content: center;
      background: var(--bg); padding: 24px;
    }
    .auth-card {
      background: #fff; border-radius: var(--r-lg);
      box-shadow: var(--shadow); border: 1px solid var(--border);
      padding: 40px 36px; width: 100%; max-width: 400px;
    }
    .auth-logo {
      display: flex; align-items: center; gap: 10px;
      justify-content: center; margin-bottom: 28px;
    }
    .auth-logo-icon {
      width: 42px; height: 42px;
      border-radius: 10px;
      display: flex; align-items: center; justify-content: center;
      position: relative; overflow: hidden;
    }
    .auth-logo-icon::after {
      content: ''; position: absolute; inset: 0;
      background: var(--brand); mix-blend-mode: screen; pointer-events: none;
    }
    .auth-logo-icon-img {
      width: 100%; height: 100%; object-fit: contain;
    }
    .auth-logo-name { font-size: 19px; font-weight: 700; color: var(--brand); }
    .auth-title { font-size: 16px; font-weight: 700; text-align: center; margin-bottom: 22px; color: var(--text); }

    .form-group { margin-bottom: 14px; }
    .form-group label { display: block; font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 5px; }
    .form-control {
      width: 100%; padding: 10px 13px;
      border: 1px solid var(--border); border-radius: var(--r);
      font-size: 14px; font-family: inherit; color: var(--text); background: #fff;
      transition: border-color .14s; outline: none;
    }
    .form-control:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(0,143,163,.1); }

    .form-error {
      color: var(--error); font-size: 12px; margin-bottom: 14px;
      padding: 8px 12px; background: #fff5f5;
      border-radius: var(--r); border: 1px solid #fcc;
    }
    .btn-primary {
      width: 100%; padding: 11px;
      background: var(--brand); color: #fff; border: none;
      border-radius: var(--r); font-size: 14px; font-weight: 600;
      cursor: pointer; transition: background .14s; font-family: inherit;
    }
    .btn-primary:hover { background: var(--brand-dark); }

    /* Misc buttons */
    .btn-icon {
      background: none; border: none; cursor: pointer;
      padding: 3px 5px; border-radius: var(--r-sm);
      color: var(--sub); font-size: 13px; line-height: 1;
    }
    .btn-icon:hover { background: var(--brand-light); color: var(--brand); }

    .btn-outline {
      padding: 5px 14px; border-radius: var(--r);
      border: 1px solid var(--border); background: #fff;
      color: var(--sub); font-size: 13px; cursor: pointer;
      transition: all .14s; font-family: inherit;
    }
    .btn-outline:hover { border-color: var(--brand); color: var(--brand); background: var(--brand-light); }

    /* Character widget */
    .character-widget {
      position: fixed; bottom: 60px; right: -24px; z-index: 50;
      width: 378px;
    }
    .character-btn {
      width: 378px; height: 504px;
      background: none; border: none; cursor: pointer;
      display: flex; align-items: center; justify-content: center;
      padding: 0; position: relative;
      outline: none;
      overflow: visible;
      box-shadow: none;
    }
    .character-btn:focus,
    .character-btn:focus-visible {
      outline: none;
      box-shadow: none;
    }
    .character-btn:hover { cursor: pointer; }
    .character-model {
      width: 100%; height: 100%;
      pointer-events: none;
      background-position: center;
      background-repeat: no-repeat;
      background-size: contain;
    }
    .character-model.is-ready { background-image: none !important; }
    .character-model canvas {
      display: block;
      width: 100%;
      height: 100%;
      backface-visibility: hidden;
    }
    .character-model-main {
      filter: drop-shadow(0 7px 10px rgba(0, 143, 163, .16));
    }

    .character-popup {
      position: fixed; bottom: 320px; right: 8px;
      width: 280px;
      background: #fff; border: 1.5px solid var(--border);
      border-radius: 20px; box-shadow: 0 6px 24px rgba(0,143,163,.13);
      padding: 16px; display: none; z-index: 2;
    }
    .character-popup.show { display: block; }
    /* 吹き出しの尻尾（下向き、キャラクター側へ） */
    .character-popup::before {
      content: ''; position: absolute;
      bottom: -15px; left: 50%; transform: translateX(-50%);
      width: 0; height: 0;
      border: 15px solid transparent;
      border-top-color: var(--border); border-bottom: 0;
    }
    .character-popup::after {
      content: ''; position: absolute;
      bottom: -12px; left: 50%; transform: translateX(-50%);
      width: 0; height: 0;
      border: 12px solid transparent;
      border-top-color: #fff; border-bottom: 0;
    }
    /* ポップアップ表示中はヒントを非表示 */
    .character-popup.show + .character-hint { opacity: 0; }
    .character-popup-header {
      display: flex; align-items: center; justify-content: flex-end; margin-bottom: 10px;
    }
    .character-popup-icon {
      width: 32px; height: 32px; border-radius: 50%;
      background: var(--brand-light); border: 2px solid var(--border);
      display: flex; align-items: center; justify-content: center;
      overflow: hidden;
    }
    .character-popup-icon .character-model { transform: scale(1.18); }
    .character-popup-name { font-size: 13px; font-weight: 600; color: var(--brand); flex: 1; }
    .character-popup-close {
      background: none; border: none; cursor: pointer; color: var(--sub); font-size: 16px; padding: 2px;
    }
    .character-popup-msg {
      font-size: 13px; color: var(--text); background: var(--bg);
      padding: 10px 12px; border-radius: var(--r); border: 1px solid var(--border);
      margin-bottom: 10px; line-height: 1.6;
    }
    .character-suggestions { display: flex; flex-direction: column; gap: 5px; }
    .character-suggestion-btn {
      text-align: left; padding: 7px 10px;
      background: var(--brand-light); border: 1px solid var(--border);
      border-radius: var(--r); font-size: 12px; color: var(--brand);
      cursor: pointer; font-family: inherit; transition: background .12s;
    }
    .character-suggestion-btn:hover { background: #bde8ee; }

    /* ヒント吹き出し「...」 */
    .character-hint {
      position: fixed; z-index: 51; visibility: hidden;
      background: #fff; border: 1.5px solid var(--border);
      border-radius: 100px;  /* 楕円形の吹き出し */
      padding: 12px 22px;
      box-shadow: 0 2px 12px rgba(0,143,163,.10);
      display: flex; gap: 6px; align-items: center;
      pointer-events: none;
      transition: opacity .2s;
      white-space: nowrap;
    }
    /* 右向き尻尾（キャラクター側へ） */
    .character-hint::before {
      content: ''; position: absolute;
      right: -14px; top: 50%; transform: translateY(-50%);
      width: 0; height: 0;
      border: 14px solid transparent;
      border-left-color: var(--border); border-right: 0;
    }
    .character-hint::after {
      content: ''; position: absolute;
      right: -11px; top: 50%; transform: translateY(-50%);
      width: 0; height: 0;
      border: 11px solid transparent;
      border-left-color: #fff; border-right: 0;
    }
    .hint-dot {
      width: 7px; height: 7px; border-radius: 50%;
      background: var(--brand); opacity: .35;
      animation: hint-bounce 1.4s infinite ease-in-out;
    }
    .hint-dot:nth-child(1) { animation-delay: 0s; }
    .hint-dot:nth-child(2) { animation-delay: .2s; }
    .hint-dot:nth-child(3) { animation-delay: .4s; }
    @keyframes hint-bounce {
      0%, 60%, 100% { opacity: .35; transform: translateY(0); }
      30% { opacity: 1; transform: translateY(-3px); }
    }
    @media (prefers-reduced-motion: reduce) {
      .hint-dot { animation: none; opacity: .6; }
      .character-hint { transition: none; }
    }

    /* ── Ops / admin page styles (backward compat) ── */
    .ops-section { margin: 1.2rem 0 1.8rem; }
    .ops-section h2 {
      font-size: 1rem; font-weight: bold;
      border-bottom: 2px solid var(--brand);
      padding-bottom: .3rem; margin-bottom: .8rem; color: var(--brand-dark);
    }
    .ops-table { width: 100%; border-collapse: collapse; font-size: .875rem; }
    .ops-table th, .ops-table td { text-align: left; padding: .4rem .6rem; border: 1px solid var(--border); }
    .ops-table th { background: var(--brand-light); font-weight: bold; }
    .badge-ok   { color: var(--success); font-weight: bold; }
    .badge-err  { color: var(--error); font-weight: bold; }
    .badge-warn { color: var(--warning); font-weight: bold; }
    .ops-meta   { font-size: .8rem; color: #666; margin-top: .3rem; }
    .audit-action-1 { color: #2980b9; }
    .audit-action-2 { color: #e67e22; }
    .audit-action-3 { color: var(--error); }
    .audit-action-view { color: #8e44ad; }

    /* ── Mobile-only elements: hidden on desktop ── */
    .mobile-header    { display: none; }
    .sidebar-backdrop { display: none !important; }

    @media (max-width: 760px) {
      body { min-width: 0; }

      /* Mobile top bar */
      .mobile-header {
        display: flex; align-items: center; gap: 12px;
        padding: 10px 16px; flex-shrink: 0;
        background: #fff; border-bottom: 1px solid var(--border);
        z-index: 100;
      }
      .mobile-hamburger {
        background: none; border: none; cursor: pointer;
        padding: 5px; border-radius: var(--r-sm);
        color: var(--text); display: flex; align-items: center;
        transition: background .12s;
      }
      .mobile-hamburger:hover { background: var(--brand-light); color: var(--brand); }
      .mobile-header-title {
        font-size: 15px; font-weight: 700; color: var(--brand); letter-spacing: .01em;
      }

      /* Sidebar: slide-in overlay */
      .sidebar {
        position: fixed;
        top: 0; left: 0; bottom: 0;
        width: 280px;
        z-index: 400;
        transform: translateX(-100%);
        transition: transform .26s cubic-bezier(.4,0,.2,1);
        box-shadow: 4px 0 24px rgba(0,0,0,.18);
        border-right: 1px solid var(--border);
        overflow-y: auto;
      }
      .sidebar.open { transform: translateX(0); }

      /* Backdrop */
      .sidebar-backdrop {
        display: block !important; /* override desktop hide */
        position: fixed; inset: 0; z-index: 399;
        background: rgba(0,0,0,.38);
        opacity: 0; pointer-events: none;
        transition: opacity .26s ease;
      }
      .sidebar-backdrop.show { opacity: 1; pointer-events: auto; }

      /* Chat area fills full width (sidebar is out-of-flow) */
      .chat-area { min-height: 0; width: 100%; }
      .messages { padding: 16px 12px; gap: 12px; }
      .bubble.user { max-width: 88%; }
      .bubble.assistant { padding: 14px 16px; }
      .input-area { padding: 10px 12px 12px; }
      .input-card { padding: 9px 10px; }
      .character-widget { right: -10px; bottom: 60px; width: 234px; }
      .character-btn { width: 234px; height: 306px; }
      .character-popup {
        right: 4px; bottom: 255px;
        width: min(280px, calc(100vw - 24px));
      }
    }
