/* AI character creator (js/views/ai-creator.js). Fixed between the site
   header and the phone navigation; follows the visual viewport so the iOS
   keyboard never covers the composer. Inputs are ≥16px: iOS zooms below that. */
.cr {
    --cr-bg: #313338;
    --cr-panel: #2b2d31;
    --cr-panel-2: #1e1f22;
    --cr-line: rgba(255, 255, 255, 0.08);
    --cr-text: #ececf1;
    --cr-muted: #a3a6b0;
    --cr-accent: #8b5cf6;
    --cr-accent-2: #ae99ff;
    --cr-pink: #f786f4;
    --cr-top: 64px;
    --cr-dock: 0px;
    --cr-vh: 100dvh;
    --cr-vtop: 0px;
    position: fixed;
    left: 0;
    right: 0;
    top: var(--cr-top);
    height: calc(var(--cr-vh) - var(--cr-top) - var(--cr-dock));
    transform: translateY(var(--cr-vtop));
    z-index: 90;
    display: flex;
    flex-direction: column;
    background: var(--cr-bg);
    color: var(--cr-text);
    font-size: 15px;
    padding-left: env(safe-area-inset-left, 0px);
    padding-right: env(safe-area-inset-right, 0px);
}
.cr[hidden], .cr [hidden] { display: none !important; }
.cr *, .cr *::before, .cr *::after { box-sizing: border-box; }
.cr button { font: inherit; color: inherit; cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
.cr button:disabled { opacity: 0.45; cursor: default; }
.cr input, .cr textarea, .cr select { font: inherit; font-size: 16px; color: var(--cr-text); }
.cr-icon { width: 20px; height: 20px; flex-shrink: 0; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

html.cr-open, html.cr-open body { overflow: hidden; overscroll-behavior: none; }
html.cr-open footer, html.cr-open .footer { display: none; }

/* Top bar */
.cr-top { flex-shrink: 0; display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-bottom: 1px solid var(--cr-line); background: var(--cr-panel); min-width: 0; }
.cr-icon-btn { flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; border: 1px solid var(--cr-line); border-radius: 10px; background: var(--cr-panel-2); color: var(--cr-muted); }
.cr-icon-btn:hover:not(:disabled) { color: #fff; border-color: rgba(255, 255, 255, 0.18); }
.cr-icon-btn.sm { width: 34px; height: 34px; border-radius: 8px; }
.cr-icon-btn.sm .cr-icon { width: 17px; height: 17px; }
.cr-draft-btn { flex: 1 1 auto; min-width: 0; display: flex; align-items: center; gap: 9px; padding: 4px 8px 4px 4px; border: 1px solid transparent; border-radius: 12px; background: transparent; text-align: left; }
.cr-draft-btn:hover { background: var(--cr-panel-2); border-color: var(--cr-line); }
.cr-draft-btn > .cr-icon { width: 16px; height: 16px; color: var(--cr-muted); }
.cr-draft-avatar { width: 36px; height: 36px; border-radius: 10px; object-fit: cover; background: var(--cr-panel-2); flex-shrink: 0; }
.cr-draft-text { min-width: 0; display: flex; flex-direction: column; line-height: 1.2; }
.cr-draft-name { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cr-draft-status { font-size: 12px; color: var(--cr-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-height: 14px; }
.cr-save { flex-shrink: 0; display: inline-flex; align-items: center; gap: 7px; height: 40px; padding: 0 16px; border: 0; border-radius: 10px; background: linear-gradient(135deg, #805ad5, #6366f1); color: #fff; font-weight: 700; }
.cr-save:hover:not(:disabled) { filter: brightness(1.1); }
.cr-seg { display: none; flex-shrink: 0; padding: 3px; gap: 2px; border-radius: 11px; background: var(--cr-panel-2); border: 1px solid var(--cr-line); }
.cr-seg button { position: relative; height: 34px; padding: 0 12px; border: 0; border-radius: 8px; background: transparent; color: var(--cr-muted); font-weight: 600; font-size: 14px; }
.cr-seg button[aria-selected="true"] { background: #3a3c43; color: #fff; }
.cr-badge { display: inline-flex; align-items: center; justify-content: center; min-width: 18px; height: 18px; margin-left: 4px; padding: 0 5px; border-radius: 9px; background: var(--cr-pink); color: #1e1f22; font-size: 11px; font-weight: 800; }

/* Body: chat | card */
.cr-body { flex: 1 1 auto; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.cr-chat { min-height: 0; min-width: 0; display: flex; flex-direction: column; border-right: 1px solid var(--cr-line); }
.cr-card { min-height: 0; min-width: 0; display: flex; flex-direction: column; background: #2a2b30; }
@media (min-width: 1200px) { .cr-body { grid-template-columns: minmax(0, 11fr) minmax(0, 10fr); } }

.cr-log { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.cr-msg { display: flex; flex-direction: column; gap: 6px; max-width: min(88%, 680px); }
.cr-msg-user { align-self: flex-end; align-items: flex-end; }
.cr-msg-ai { align-self: flex-start; }
.cr-bubble { padding: 10px 14px; border-radius: 16px; line-height: 1.55; white-space: pre-wrap; overflow-wrap: anywhere; }
.cr-msg-ai .cr-bubble { background: var(--cr-panel-2); border: 1px solid var(--cr-line); border-top-left-radius: 6px; }
.cr-msg-user .cr-bubble { background: rgba(128, 90, 213, 0.22); border: 1px solid rgba(128, 90, 213, 0.38); border-top-right-radius: 6px; }
.cr-bubble code { font-size: 0.9em; padding: 1px 5px; border-radius: 5px; background: rgba(255, 255, 255, 0.08); }
.cr-changes { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; padding: 7px 10px; border-radius: 10px; background: rgba(174, 153, 255, 0.1); border: 1px solid rgba(174, 153, 255, 0.25); font-size: 13px; color: #d9d0ff; }
.cr-changes.is-undone .cr-changes-list { text-decoration: line-through; opacity: 0.7; }
.cr-errors { padding: 6px 10px; border-radius: 10px; background: rgba(245, 158, 11, 0.1); color: #fcd34d; font-size: 12.5px; }
.cr-note { align-self: center; max-width: 92%; padding: 5px 12px; border-radius: 999px; background: rgba(255, 255, 255, 0.05); color: var(--cr-muted); font-size: 13px; text-align: center; overflow-wrap: anywhere; }
.cr-link { display: inline-flex; align-items: center; gap: 4px; padding: 4px 2px; border: 0; background: none; color: var(--cr-accent-2); font-weight: 600; font-size: 13px; }
.cr-link .cr-icon { width: 15px; height: 15px; }
.cr-link:hover { color: #fff; }
.cr-typing { align-self: flex-start; display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: 16px; background: var(--cr-panel-2); color: var(--cr-muted); font-size: 14px; }
.cr-dots { display: inline-flex; gap: 4px; }
.cr-dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--cr-accent); animation: crBounce 1.4s infinite ease-in-out both; }
.cr-dots i:nth-child(2) { animation-delay: 0.2s; }
.cr-dots i:nth-child(3) { animation-delay: 0.4s; }
@keyframes crBounce { 0%, 80%, 100% { transform: scale(0); } 40% { transform: scale(1); } }

.cr-chips { flex-shrink: 0; display: flex; gap: 8px; padding: 0 12px 8px; overflow-x: auto; scrollbar-width: none; }
.cr-chips::-webkit-scrollbar { display: none; }
.cr-chip { flex-shrink: 0; padding: 7px 12px; border: 1px solid rgba(255, 255, 255, 0.12); border-radius: 999px; background: var(--cr-panel-2); color: var(--cr-muted); font-size: 13.5px; white-space: nowrap; }
.cr-chip:hover { color: #fff; border-color: rgba(174, 153, 255, 0.5); }

.cr-composer { flex-shrink: 0; display: flex; align-items: flex-end; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--cr-line); background: var(--cr-panel); }
.cr-input { flex: 1 1 auto; min-width: 0; min-height: 44px; max-height: 160px; padding: 10px 14px; border: 1px solid #3f4147; border-radius: 14px; background: var(--cr-panel-2); line-height: 1.4; resize: none; outline: none; }
.cr-input:focus { border-color: rgba(139, 92, 246, 0.7); }
.cr-composer .cr-icon-btn { width: 44px; height: 44px; border-radius: 12px; }
.cr-send { flex-shrink: 0; width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center; border: 0; border-radius: 12px; background: linear-gradient(135deg, #805ad5, #6366f1); color: #fff; }
.cr-send.is-stop { background: #3f4147; }

/* Card panel */
.cr-card-tabs { flex-shrink: 0; display: flex; gap: 4px; padding: 8px 12px; border-bottom: 1px solid var(--cr-line); }
.cr-card-tabs button { flex: 1; height: 36px; border: 0; border-radius: 9px; background: transparent; color: var(--cr-muted); font-weight: 600; }
.cr-card-tabs button[aria-selected="true"] { background: #3a3c43; color: #fff; }
.cr-card-scroll { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; padding: 14px 16px 24px; }

.cr-hero { display: flex; gap: 14px; align-items: flex-start; margin-bottom: 12px; border-radius: 14px; }
.cr-avatar { position: relative; flex-shrink: 0; width: 112px; aspect-ratio: 3 / 4; padding: 0; border: 1px solid var(--cr-line); border-radius: 12px; overflow: hidden; background: var(--cr-panel-2); }
.cr-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cr-avatar-edit { position: absolute; left: 0; right: 0; bottom: 0; display: flex; align-items: center; justify-content: center; gap: 4px; padding: 6px 4px; background: rgba(0, 0, 0, 0.62); font-size: 12px; font-weight: 600; }
.cr-avatar-edit .cr-icon { width: 14px; height: 14px; }
.cr-hero-text { min-width: 0; flex: 1; }
.cr-name { margin: 2px 0 4px; font-size: 20px; line-height: 1.25; color: var(--cr-pink); overflow-wrap: anywhere; }
.cr-tagline { margin: 0 0 8px; color: #d7d7dd; font-size: 14px; line-height: 1.45; overflow-wrap: anywhere; }
.cr-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.cr-tag { padding: 3px 9px; border-radius: 999px; border: 1px solid rgba(88, 251, 216, 0.25); color: #7ee7d3; font-size: 12.5px; }
.cr-tag.is-nsfw { border-color: rgba(248, 113, 113, 0.4); color: #fca5a5; }
.cr-check { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 12px; }
.cr-check span { padding: 4px 10px; border-radius: 999px; background: rgba(245, 158, 11, 0.12); color: #fcd34d; font-size: 12.5px; }
.cr-check.is-ok span { background: rgba(34, 197, 94, 0.12); color: #86efac; }
.cr-sec { margin-bottom: 10px; border: 1px solid var(--cr-line); border-radius: 12px; background: var(--cr-panel-2); }
.cr-sec summary { padding: 10px 14px; font-weight: 600; cursor: pointer; list-style-position: inside; }
.cr-sec-body { padding: 0 14px 14px; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.6; color: #d7d7dd; font-size: 14px; }
.cr-sec-body em { color: #c4b5fd; }
.cr-empty, .cr-muted { color: var(--cr-muted); font-size: 13.5px; }
.cr-lore { padding: 8px 0; border-top: 1px solid var(--cr-line); white-space: normal; }
.cr-lore:first-child { border-top: 0; padding-top: 0; }
.cr-lore div { white-space: pre-wrap; margin-top: 4px; }
.cr-lore-keys { color: var(--cr-muted); font-size: 12.5px; }
.is-flash { animation: crFlash 1.8s ease-out; border-radius: 8px; }
@keyframes crFlash { 0% { box-shadow: 0 0 0 2px rgba(247, 134, 244, 0.85); } 100% { box-shadow: 0 0 0 2px rgba(247, 134, 244, 0); } }

.cr-ghost-btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 40px; padding: 0 14px; border: 1px solid rgba(255, 255, 255, 0.14); border-radius: 10px; background: transparent; color: #e5e7eb; font-weight: 600; font-size: 14px; }
.cr-ghost-btn:hover { border-color: rgba(174, 153, 255, 0.6); color: #fff; }
.cr-ghost-btn .cr-icon { width: 17px; height: 17px; }
.cr-ghost-btn.wide, .cr-primary-btn { width: 100%; }
.cr-primary-btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; padding: 0 16px; border: 0; border-radius: 12px; background: linear-gradient(135deg, #805ad5, #6366f1); color: #fff; font-weight: 700; }

/* Editor */
.cr-field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; min-width: 0; }
.cr-field > span, .cr-group-head > span { font-size: 12.5px; font-weight: 700; color: var(--cr-muted); text-transform: uppercase; letter-spacing: 0.03em; }
.cr-editor input[type="text"], .cr-editor textarea, .cr-editor select, .cr-sheet input[type="text"], .cr-sheet input[type="url"], .cr-sheet input[type="search"], .cr-sheet input[type="password"], .cr-sheet select {
    width: 100%; min-height: 44px; padding: 10px 12px; border: 1px solid #3f4147; border-radius: 10px; background: var(--cr-panel-2); outline: none; line-height: 1.5;
}
.cr-editor textarea { resize: vertical; min-height: 88px; }
/* WebKit draws native light selects otherwise (white box, unreadable text). */
.cr select { -webkit-appearance: none; appearance: none; padding-right: 34px !important; background-color: var(--cr-panel-2); color: var(--cr-text);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%23a3a6b0' stroke-width='2'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 12px center; }
.cr-editor input:focus, .cr-editor textarea:focus, .cr-sheet input:focus, .cr-sheet select:focus { border-color: rgba(139, 92, 246, 0.7); }
.cr-avatar-row { flex-direction: row; align-items: center; gap: 12px; }
.cr-avatar-row img { width: 64px; height: 64px; border-radius: 12px; object-fit: cover; background: var(--cr-panel-2); }
.cr-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.cr-check-field { display: flex; align-items: center; gap: 10px; min-height: 44px; margin-bottom: 14px; color: #d1d5db; }
.cr-check-field input { width: 20px; height: 20px; accent-color: var(--cr-accent); }
.cr-group { margin: 4px 0 16px; padding: 12px; border: 1px solid var(--cr-line); border-radius: 12px; background: rgba(0, 0, 0, 0.12); }
.cr-group-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.cr-item { display: flex; flex-direction: column; gap: 8px; padding: 10px 0; border-top: 1px solid var(--cr-line); }
.cr-item-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 13.5px; font-weight: 600; color: #d1d5db; }
.cr-item-tools { display: inline-flex; gap: 6px; }
.cr-item .cr-check-field { margin-bottom: 0; }

/* Sheets: bottom sheet on phones, dialog on desktop */
.cr-sheet-layer { position: fixed; inset: 0; z-index: 1200; display: flex; align-items: center; justify-content: center; padding: 16px; }
.cr-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.6); }
.cr-sheet { position: relative; width: min(460px, 100%); max-height: min(720px, 100%); display: flex; flex-direction: column; border: 1px solid rgba(255, 255, 255, 0.12); border-radius: 16px; background: #26272c; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5); }
.cr-sheet.is-wide { width: min(620px, 100%); }
.cr-sheet-head { flex-shrink: 0; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 12px 8px 18px; }
.cr-sheet-head h3 { margin: 0; font-size: 18px; }
.cr-sheet-body { min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 4px 18px 18px; display: flex; flex-direction: column; gap: 12px; }
.cr-sheet-body .cr-field { margin-bottom: 0; }
.cr-sub { margin: 6px 0 0; font-size: 14px; color: var(--cr-muted); }
.cr-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.cr-list li { display: flex; align-items: center; gap: 8px; padding: 6px; border-radius: 12px; background: var(--cr-panel-2); border: 1px solid var(--cr-line); min-width: 0; }
.cr-list li.is-current { border-color: rgba(174, 153, 255, 0.5); }
.cr-list li.cr-muted { padding: 12px; justify-content: center; }
.cr-list-main { flex: 1 1 auto; min-width: 0; display: flex; align-items: center; gap: 10px; padding: 2px; border: 0; background: none; text-align: left; }
.cr-list-main img { width: 44px; height: 44px; border-radius: 10px; object-fit: cover; flex-shrink: 0; background: #2b2d31; }
.cr-list-main span { min-width: 0; display: flex; flex-direction: column; }
.cr-list-main strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cr-list-main small { color: var(--cr-muted); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cr-list-actions { flex-shrink: 0; display: inline-flex; gap: 6px; }
.cr-list-actions .cr-ghost-btn { padding: 0 10px; font-size: 13px; }
.cr-url-row { display: flex; gap: 8px; margin-top: 10px; }
.cr-url-row input { flex: 1; min-width: 0; }
.cr-avatar-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); gap: 8px; }
.cr-avatar-grid button { padding: 0; aspect-ratio: 3 / 4; border: 1px solid var(--cr-line); border-radius: 10px; overflow: hidden; background: var(--cr-panel-2); }
.cr-avatar-grid button:hover { border-color: rgba(174, 153, 255, 0.8); }
.cr-avatar-grid img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* Booru avatar candidates (chat strip and avatar sheet) */
.cr-booru-msg { align-self: stretch; display: flex; flex-direction: column; gap: 8px; padding: 10px; border-radius: 14px; background: var(--cr-panel-2); border: 1px solid var(--cr-line); min-width: 0; }
.cr-booru-head { font-size: 13px; font-weight: 600; color: var(--cr-muted); overflow-wrap: anywhere; }
.cr-booru-strip { display: flex; gap: 8px; overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: thin; padding-bottom: 2px; }
.cr-booru-strip .cr-booru-thumb { flex: 0 0 auto; width: 96px; }
.cr-booru-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.cr-booru-thumb { position: relative; padding: 0; aspect-ratio: 3 / 4; border: 1px solid var(--cr-line); border-radius: 10px; overflow: hidden; background: #2b2d31; }
.cr-booru-thumb:hover { border-color: rgba(174, 153, 255, 0.8); }
.cr-booru-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cr-booru-thumb.is-missing { opacity: 0.35; }
.cr-booru-rating { position: absolute; top: 4px; right: 4px; padding: 1px 6px; border-radius: 6px; background: rgba(0, 0, 0, 0.7); color: #fca5a5; font-size: 11px; font-weight: 700; }
.cr-booru-tools { display: flex; gap: 14px; flex-wrap: wrap; }
.cr-booru-form { display: flex; flex-direction: column; gap: 8px; }
.cr-booru-row { display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px; }
.cr-booru-row select { min-width: 0; }
.cr-booru-accounts { border: 1px solid var(--cr-line); border-radius: 12px; background: var(--cr-panel-2); }
.cr-booru-accounts summary { padding: 10px 14px; cursor: pointer; font-weight: 600; font-size: 14px; }
.cr-booru-accounts-body { padding: 0 14px 14px; display: flex; flex-direction: column; gap: 12px; }
.cr-account { display: flex; flex-direction: column; gap: 6px; }
.cr-account input { width: 100%; min-height: 44px; padding: 10px 12px; border: 1px solid #3f4147; border-radius: 10px; background: #26272c; outline: none; }
.cr-account .cr-ghost-btn { align-self: flex-start; }
.cr-masked { -webkit-text-security: disc; text-security: disc; }

/* Pager and large viewer */
.cr-pager { display: inline-flex; align-items: center; gap: 10px; color: var(--cr-muted); font-size: 13.5px; font-weight: 600; }
.cr-sheet .cr-pager { align-self: center; margin-top: 4px; }
.cr-flip .cr-icon { transform: rotate(180deg); }
.cr-booru-tools { align-items: center; }
.cr-viewer { position: absolute; inset: 0; z-index: 1300; display: flex; flex-direction: column; background: rgba(8, 8, 10, 0.96); padding-bottom: env(safe-area-inset-bottom, 0px); }
.cr-viewer[hidden] { display: none !important; }
.cr-viewer-top { flex-shrink: 0; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 10px 8px 16px; color: #d1d5db; font-size: 14px; font-weight: 600; }
.cr-viewer-stage { position: relative; flex: 1 1 auto; min-height: 0; display: flex; align-items: center; justify-content: center; padding: 0 8px; touch-action: pan-y pinch-zoom; user-select: none; -webkit-user-select: none; }
.cr-viewer-img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 10px; -webkit-user-drag: none; transition: filter 0.2s; }
.cr-viewer-img.is-preview { filter: blur(6px); }
.cr-viewer-badge { position: absolute; top: 10px; right: 18px; padding: 2px 8px; border-radius: 8px; background: rgba(0, 0, 0, 0.7); color: #fca5a5; font-size: 12px; font-weight: 700; }
.cr-viewer-loading { position: absolute; bottom: 14px; left: 50%; transform: translateX(-50%); padding: 8px 12px; border-radius: 999px; background: rgba(0, 0, 0, 0.6); }
.cr-viewer-bar { flex-shrink: 0; display: grid; grid-template-columns: 56px 1fr 56px; gap: 10px; align-items: center; padding: 10px 12px 12px; }
.cr-viewer-nav { height: 52px; border: 1px solid rgba(255, 255, 255, 0.16); border-radius: 14px; background: rgba(255, 255, 255, 0.06); color: #fff; display: inline-flex; align-items: center; justify-content: center; }
.cr-viewer-nav:disabled { opacity: 0.3; }
.cr-viewer-nav .cr-icon { width: 24px; height: 24px; }
.cr-viewer-pick { min-height: 52px; font-size: 16px; }
@media (min-width: 900px) {
    .cr-viewer-bar { max-width: 560px; width: 100%; margin: 0 auto; }
}

.cr-toast { position: absolute; z-index: 1400; left: 50%; bottom: 76px; transform: translateX(-50%); max-width: calc(100% - 32px); padding: 10px 16px; border-radius: 12px; background: #111214; border: 1px solid rgba(255, 255, 255, 0.12); color: #fff; font-size: 14px; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45); text-align: center; }
.cr-only-narrow { display: none; }

/* Phones and narrow tablets: one pane at a time */
@media (max-width: 899px) {
    .cr-body { display: flex; }
    .cr-chat, .cr-card { flex: 1 1 auto; width: 100%; border-right: 0; }
    .cr[data-pane="chat"] .cr-card, .cr[data-pane="card"] .cr-chat { display: none; }
    .cr-seg { display: inline-flex; }
    .cr-only-narrow { display: inline-flex; }
    .cr-log { padding: 12px; }
    .cr-msg { max-width: 92%; }
    .cr-card-scroll { padding: 12px 12px 24px; }
}
/* The site's phone navigation sits below; measure() sets --cr-dock to its
   real height. With the keyboard open it is hidden behind the keyboard, so
   the creator uses the full visual viewport. */
@media (max-width: 768px) {
    html.cr-kb .mobile-bottom-nav { visibility: hidden; }
    .cr-sheet-layer { align-items: flex-end; padding: 0; }
    .cr-sheet, .cr-sheet.is-wide { width: 100%; max-height: calc(100% - 12px); border-radius: 18px 18px 0 0; border-bottom: 0; padding-bottom: env(safe-area-inset-bottom, 0px); }
}
@media (max-width: 480px) {
    /* The drafts sheet carries "Diğer yöntemler" instead. */
    .cr-back, .cr-draft-status { display: none; }
}
@media (max-width: 560px) {
    .cr-top { gap: 6px; padding: 6px 8px; }
    .cr-save { width: 40px; padding: 0; justify-content: center; }
    .cr-save-label { display: none; }
    .cr-draft-btn > .cr-icon { display: none; }
    .cr-draft-avatar { width: 32px; height: 32px; }
    .cr-seg button { padding: 0 9px; font-size: 13.5px; }
    .cr-avatar { width: 92px; }
    .cr-name { font-size: 18px; }
    .cr-row { grid-template-columns: 1fr; gap: 0; }
    .cr-booru-row { grid-template-columns: 1fr 1fr; }
    .cr-booru-row .cr-ghost-btn { grid-column: 1 / -1; }
    .cr-lib-list li { flex-wrap: wrap; }
    .cr-list-actions { width: 100%; }
    .cr-list-actions .cr-ghost-btn { flex: 1; }
}
@media (max-width: 360px) {
    .cr-composer { gap: 6px; padding: 8px; }
    .cr-composer .cr-icon-btn, .cr-send { width: 42px; height: 42px; }
}

/* Create → İçe aktar (js/views/create-view.js): files and optional pasted
   JSON share one queue. Inputs ≥16px so iOS does not zoom. */
.ci { --ci-panel: #2b2d31; --ci-panel-2: #1e1f22; --ci-line: rgba(255, 255, 255, 0.08); --ci-muted: #a3a6b0; color: #ececf1; }
.ci *, .ci *::before, .ci *::after { box-sizing: border-box; }
.ci [hidden] { display: none !important; }
.ci-panel { display: flex; flex-direction: column; gap: 14px; padding: 18px; background: var(--ci-panel); border: 1px solid var(--ci-line); border-radius: 14px; }
.ci-drop { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; min-height: 150px; padding: 22px 16px; border: 2px dashed #3f4147; border-radius: 14px; text-align: center; cursor: pointer; transition: border-color 0.2s, background 0.2s; -webkit-tap-highlight-color: transparent; }
.ci-drop:hover, .ci-drop:focus-visible, .ci-drop.is-active { border-color: #805ad5; background: rgba(128, 90, 213, 0.08); outline: none; }
.ci-drop-icon { width: 34px; height: 34px; fill: none; stroke: #ae99ff; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.ci-drop-title { font-weight: 700; font-size: 16px; }
.ci-drop-sub { color: var(--ci-muted); font-size: 13px; line-height: 1.4; }
.ci-paste { border: 1px solid var(--ci-line); border-radius: 12px; background: var(--ci-panel-2); }
.ci-paste > summary { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 10px; padding: 13px 16px; cursor: pointer; font-weight: 700; list-style: none; -webkit-tap-highlight-color: transparent; }
.ci-paste > summary::-webkit-details-marker { display: none; }
.ci-paste > summary::before { content: '▸'; color: #ae99ff; transition: transform 0.15s; }
.ci-paste[open] > summary::before { transform: rotate(90deg); }
.ci-paste > summary small { color: var(--ci-muted); font-weight: 500; font-size: 13px; }
.ci-paste-body { display: flex; flex-direction: column; gap: 10px; padding: 0 14px 14px; }
.ci textarea, .ci input[type="text"] { width: 100%; font: inherit; font-size: 16px; color: #ececf1; background: #26272c; border: 1px solid #3f4147; border-radius: 10px; outline: none; }
.ci textarea { min-height: 140px; padding: 12px; font-family: Consolas, Monaco, 'JetBrains Mono', monospace; font-size: 16px; line-height: 1.45; resize: vertical; }
.ci textarea:focus, .ci input[type="text"]:focus { border-color: rgba(139, 92, 246, 0.7); }
.ci-paste-actions { display: flex; justify-content: flex-end; }
.ci-help { border-top: 1px solid var(--ci-line); padding-top: 8px; color: #c9cbd2; font-size: 14px; }
.ci-help summary { cursor: pointer; color: #ae99ff; font-weight: 600; padding: 4px 0; }
.ci-help ol { margin: 8px 0; padding-left: 20px; line-height: 1.8; }
.ci-help a { color: #58fbd8; }
.ci-help kbd { padding: 1px 6px; border-radius: 4px; background: #374151; color: #fff; }
.ci-help p { margin: 4px 0 0; color: var(--ci-muted); }
.ci-btn { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 0 18px; border: 1px solid rgba(255, 255, 255, 0.16); border-radius: 10px; background: transparent; color: #ececf1; font: inherit; font-size: 15px; font-weight: 700; cursor: pointer; }
.ci-btn:hover:not(:disabled) { border-color: rgba(174, 153, 255, 0.7); }
.ci-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.ci-primary { width: 100%; min-height: 50px; border: 0; background: linear-gradient(135deg, #805ad5, #6366f1); color: #fff; font-size: 16px; }
.ci-link { border: 0; background: none; color: var(--ci-muted); font: inherit; font-size: 14px; cursor: pointer; padding: 6px 2px; }
.ci-queue { display: flex; flex-direction: column; gap: 10px; }
.ci-queue-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.ci-queue-head h4 { margin: 0; font-size: 15px; color: #d1d5db; }
.ci-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.ci-item { display: flex; align-items: center; gap: 12px; min-width: 0; padding: 10px; border-radius: 12px; background: var(--ci-panel-2); border: 1px solid var(--ci-line); }
.ci-item.is-error { border-color: rgba(248, 113, 113, 0.35); }
.ci-item.is-error strong { color: #fca5a5; }
.ci-avatar { position: relative; flex-shrink: 0; width: 56px; height: 72px; padding: 0; border: 1px solid var(--ci-line); border-radius: 10px; overflow: hidden; background: #111; cursor: pointer; }
.ci-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ci-avatar.is-missing img { opacity: 0.35; }
.ci-avatar span { position: absolute; inset: auto 0 0 0; padding: 3px 0; background: rgba(0, 0, 0, 0.7); color: #fcd34d; font-size: 11px; font-weight: 700; text-align: center; }
.ci-item-text { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.ci-item-text small { color: var(--ci-muted); font-size: 12.5px; line-height: 1.35; overflow-wrap: anywhere; }
.ci-item-text .ci-tagline { color: #c9cbd2; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.ci-name { min-height: 40px; padding: 7px 10px; font-weight: 700; }
.ci-icon { flex-shrink: 0; width: 40px; height: 40px; border: 0; border-radius: 10px; background: transparent; color: var(--ci-muted); font-size: 16px; cursor: pointer; }
.ci-icon:hover { color: #fff; background: rgba(255, 255, 255, 0.06); }
.ci-progress { padding: 12px; border-radius: 10px; background: rgba(0, 0, 0, 0.3); }
.ci-progress-row { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 6px; font-size: 13px; }
.ci-progress-row span:first-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ci-progress-row span:last-child { color: #58fbd8; }
.ci-progress-track { height: 6px; border-radius: 4px; background: rgba(255, 255, 255, 0.1); overflow: hidden; }
.ci-progress-track div { width: 0; height: 100%; background: linear-gradient(90deg, #58fbd8, #8b5cf6); transition: width 0.3s; }
.ci-results { padding: 14px; border-radius: 10px; background: rgba(34, 197, 94, 0.1); border: 1px solid rgba(34, 197, 94, 0.3); color: #c9cbd2; font-size: 14px; line-height: 1.6; }
.ci-results h4 { margin: 0 0 6px; color: #22c55e; }
.ci-results p { margin: 2px 0; overflow-wrap: anywhere; }
.ci-results .is-new { color: #58fbd8; } .ci-results .is-updated { color: #fbbf24; } .ci-results .is-skipped { color: #9ca3af; }
.ci-results .is-cancelled { color: #fca5a5; } .ci-results .is-failed { color: #ef4444; }
@media (max-width: 560px) {
    .create-page { padding-left: 12px !important; padding-right: 12px !important; }
    .create-tab-list .create-tab { padding: 10px 6px !important; font-size: 13.5px !important; }
    .ci-panel { padding: 12px; border-radius: 12px; }
    .ci-drop { min-height: 120px; }
}

/* Live reply while the model works; ↻ under the newest AI answer. */
.cr-live .cr-typing { align-self: flex-start; }
.cr-regen { align-self: flex-start; color: var(--cr-muted); font-weight: 500; }
.cr-regen:hover, .cr-regen:focus-visible { color: var(--cr-accent-2); }
.cr-mode { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.cr-mode label { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; border: 1px solid var(--cr-line); border-radius: 12px; cursor: pointer; font-size: 14px; }
.cr-mode label small { color: var(--cr-muted); font-size: 12px; }
.cr-mode input { position: absolute; opacity: 0; pointer-events: none; }
.cr-mode label:has(input:checked) { border-color: var(--cr-accent-2); background: rgba(255, 255, 255, 0.04); }
.cr-mode label:has(input:focus-visible) { outline: 2px solid var(--cr-accent-2); outline-offset: 2px; }
