/* ==========================================================
   Cleef Chat – forum writing form (forum/newTopic.php, composer.js)
   Loaded after index_modern.css and forum.css; uses their colours.
   ========================================================== */

.i { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* ---------- page ---------- */
.write-head { display: flex; align-items: flex-end; justify-content: space-between; flex-wrap: wrap; gap: 10px 20px; margin-bottom: 18px; }
.write-head h1 { margin: 0; font-size: 32px; font-weight: 800; letter-spacing: -0.02em; line-height: 1.15; }
.write-head p { margin: 6px 0 0; color: var(--muted); }
.back { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; font-weight: 600; color: var(--muted); }
.back:hover { color: var(--text); }

.notice { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 16px; padding: 22px 24px; }
.notice p { margin: 0; flex: 1 1 260px; }
.notice .btn { width: auto; padding: 0 22px; }
.form-error { margin: 0 0 6px; padding: 12px 16px; border-radius: 12px; border: 1px solid rgba(255, 92, 168, 0.4); background: rgba(255, 92, 168, 0.1); color: var(--pink); font-weight: 600; }

/* ---------- form ---------- */
.composer { display: grid; gap: 12px; padding: 24px 26px; }
.composer .field { margin: 0; }
.composer .field label, .composer-label { display: block; margin: 0 0 6px; font-size: 13.5px; font-weight: 700; color: var(--text); position: static; }
.composer .field input {
  width: 100%; height: 52px; padding: 0 16px;
  border-radius: 14px; border: 1px solid var(--border); background: var(--field); color: var(--text);
  font: 650 17px var(--font); outline: none; transition: border-color 0.2s, box-shadow 0.2s;
}
.composer .field input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(124, 92, 255, 0.18); }
.composer .field input::placeholder { color: var(--muted); font-weight: 500; }
.composer .field input[readonly] { color: var(--muted); background: var(--surface); cursor: not-allowed; }
.field-note { display: block; margin-top: 6px; color: var(--muted); font-size: 12.5px; }

/* edit page: facts about the post */
.edit-facts { display: grid; grid-template-columns: auto 1fr; gap: 8px 14px; margin: 0; font-size: 14px; }
.edit-facts dt { color: var(--muted); }
.edit-facts dd { margin: 0; font-weight: 600; text-align: right; }
.composer-foot a.post-act { text-decoration: none; }

.field-count { justify-self: end; margin-top: -6px; color: var(--muted); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.field .field-count { display: block; margin-top: 4px; text-align: right; }
.field-count.is-over { color: var(--pink); font-weight: 700; }
.field-count[hidden], .composer [hidden] { display: none !important; }

.composer textarea, .editor {
  width: 100%; min-height: 260px; max-height: 60vh; overflow-y: auto;
  padding: 14px 16px;
  border-radius: 14px; border: 1px solid var(--border); background: var(--field); color: var(--text);
  font: 15px/1.6 var(--font); outline: none; transition: border-color 0.2s, box-shadow 0.2s;
}
.composer textarea { resize: vertical; font-family: ui-monospace, Consolas, monospace; font-size: 14px; }
.composer textarea:focus, .editor:focus { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(124, 92, 255, 0.18); }
.composer textarea::placeholder { color: var(--muted); }
.editor { cursor: text; }
.editor.is-empty::before { content: attr(data-placeholder); float: left; height: 0; color: var(--muted); pointer-events: none; }
.editor a.yt { cursor: default; }
.editor cite { user-select: none; }

/* ---------- toolbar ---------- */
.tools {
  position: sticky; z-index: 4; top: 70px;
  display: flex; flex-wrap: wrap; align-items: center; gap: 2px;
  padding: 6px; border-radius: 14px; border: 1px solid var(--border); background: var(--bg-2);
}
.tools[hidden] { display: none; }
.tools button, .tools summary {
  display: grid; place-items: center; width: 38px; height: 38px; padding: 0;
  border: 0; border-radius: 10px; background: none; color: var(--text);
  font: 600 15px var(--font); cursor: pointer; list-style: none; transition: background 0.15s, transform 0.15s;
}
.tools summary::-webkit-details-marker { display: none; }
.tools button:hover, .tools summary:hover, .tools details[open] > summary { background: var(--surface-2); }
.tools button:active { transform: scale(0.92); }
.tools button[aria-pressed="true"]:not(.mode-btn) { background: var(--accent); color: #fff; }
.tool-gap { width: 1px; height: 22px; margin: 0 4px; background: var(--border); }

.tool-menu, .smiley-menu { position: relative; }
.tool-menu > div {
  position: absolute; z-index: 6; top: calc(100% + 6px); left: 0;
  padding: 6px; border-radius: 14px; border: 1px solid var(--border); background: var(--bg-2);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.3);
}
.color-grid { display: grid; grid-template-columns: repeat(4, 38px); }
.color-grid button::before { content: ""; width: 22px; height: 22px; border-radius: 7px; background: var(--swatch); }
.text-list { display: grid; width: max-content; min-width: 150px; }
.tools .text-list button { display: block; width: 100%; height: auto; min-height: 38px; padding: 6px 12px; text-align: left; white-space: nowrap; font-weight: 500; }
/* chat smileys: a big window in the middle of the screen, smileys at their own size (never scaled).
   A blur on the form would trap the fixed window inside it, so the form has none; the toolbar comes to the front while open. */
.composer.panel { -webkit-backdrop-filter: none; backdrop-filter: none; }
.tools:has(.smiley-menu[open]) { z-index: 70; }
.smiley-menu[open]::before { content: ""; position: fixed; inset: 0; z-index: 60; background: rgba(10, 10, 14, 0.5); }
.smiley-pop {
  position: fixed; z-index: 61; top: 50%; left: 50%; transform: translate(-50%, -50%);
  display: flex; flex-direction: column;
  width: min(820px, calc(100vw - 32px)); max-height: min(640px, calc(100vh - 48px));
  border-radius: 18px; border: 1px solid var(--border); background: var(--bg-2);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
}
.smiley-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 12px 10px 18px; border-bottom: 1px solid var(--border); }
.smiley-head b { font-size: 15px; }
.smiley-grid { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; padding: 10px; overflow-y: auto; }
.tools .chat-grid button { width: auto; height: auto; min-width: 44px; min-height: 44px; padding: 6px; border-radius: 12px; }
.chat-grid img { display: block; width: auto; height: auto; max-width: none; }
.smiley-wait { flex-basis: 100%; margin: 10px; color: var(--muted); font-size: 13px; }
.tools button[aria-busy="true"] { opacity: 0.5; pointer-events: none; }

.mode-switch { display: flex; margin-left: auto; padding: 3px; border-radius: 11px; background: var(--field-2); }
.tools .mode-switch button.mode-btn { width: auto; height: 32px; padding: 0 12px; border-radius: 8px; color: var(--muted); font-size: 13px; }
.tools .mode-switch button.mode-btn[aria-pressed="true"] { background: var(--accent); color: #fff; }

/* ---------- what people wrote (editor and preview look like a post) ---------- */
.post-body { line-height: 1.6; overflow-wrap: anywhere; }
.post-body a { color: var(--accent-2); text-decoration: underline; text-underline-offset: 2px; }
.post-body .smiley { display: inline; width: 1.25em; height: 1.25em; vertical-align: -0.25em; }
.post-body .chat-smiley { display: inline; max-width: 100%; vertical-align: middle; }
.post-body .post-img { display: block; max-width: 100%; max-height: 400px; height: auto; margin: 10px 0; border-radius: 12px; }
.post-body blockquote { margin: 10px 0; padding: 8px 14px; border-left: 3px solid var(--accent); border-radius: 4px 12px 12px 4px; background: var(--surface); font-size: 0.95em; }
.post-body cite { display: block; margin-bottom: 2px; font-size: 0.85em; font-style: normal; font-weight: 700; color: var(--muted); }
.post-body ul, .post-body ol { margin: 8px 0; padding-left: 22px; }
.post-body .post-code { margin: 10px 0; padding: 10px 14px; max-height: 380px; overflow: auto; border-radius: 10px; background: var(--surface-2); font: 13px/1.5 ui-monospace, Consolas, monospace; white-space: pre-wrap; }
.post-body .post-table { margin: 10px 0; overflow-x: auto; }
.post-body table { border-collapse: collapse; }
.post-body td { padding: 5px 10px; border: 1px solid var(--border); }
.post-body .ta-left { text-align: left; }
.post-body .ta-center { text-align: center; }
.post-body .ta-right { text-align: right; }
.yt {
  display: grid; place-content: center; justify-items: center; gap: 4px;
  aspect-ratio: 16 / 9; max-width: 480px; margin: 10px 0; padding: 16px;
  border-radius: 14px; background: #1b1530; color: #fff !important; text-decoration: none !important; text-align: center;
}
.yt span { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; }
.yt span::before { content: ""; border-top: 8px solid transparent; border-bottom: 8px solid transparent; border-left: 13px solid var(--pink); }
.yt small { opacity: 0.75; font-size: 12px; }
iframe.yt-frame { display: block; width: 100%; max-width: 480px; aspect-ratio: 16 / 9; margin: 10px 0; border: 0; border-radius: 14px; }

.composer-preview { padding: 14px 16px; border-radius: 14px; border: 1px dashed var(--border); background: var(--surface); }
.composer-preview::before { content: "Vorschau"; display: block; margin-bottom: 6px; color: var(--muted); font-size: 11.5px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; }

/* ---------- options and footer ---------- */
.staff-options { display: grid; gap: 10px; margin: 0; padding: 14px 16px; border: 1px solid var(--border); border-radius: 14px; }
.staff-options legend { padding: 0 6px; font-size: 13px; font-weight: 700; color: var(--muted); }
.staff-options .check { margin: 0; }

.composer-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 12px 16px; margin-top: 4px; }
.composer-note { flex: 1 1 240px; margin: 0; color: var(--muted); font-size: 13px; }
.post-act {
  display: inline-flex; align-items: center; gap: 6px; height: 46px; padding: 0 16px;
  border: 1px solid var(--border); border-radius: 12px; background: var(--surface); color: var(--text);
  font: 600 14.5px var(--font); cursor: pointer;
}
.post-act:hover { background: var(--surface-2); }
.post-act[aria-busy="true"] { opacity: 0.6; pointer-events: none; }
.composer-foot .send { display: inline-flex; align-items: center; justify-content: center; gap: 8px; width: auto; height: 46px; margin: 0; padding: 0 22px; }
.composer .send[aria-busy="true"] { pointer-events: none; opacity: 0.7; }
.composer-foot .post-act[hidden] { display: none; }

/* ---------- tips column ---------- */
.tips { margin: 0; padding-left: 20px; font-size: 14px; color: var(--muted); }
.tips li { margin: 8px 0; }
.tips li::marker { color: var(--accent); }
.tips b { color: var(--text); }
.bb-help { width: 100%; border-collapse: collapse; font-size: 13px; }
.bb-help td { padding: 6px 0; border-bottom: 1px solid var(--border); color: var(--muted); vertical-align: top; }
.bb-help td:first-child { padding-right: 10px; color: var(--text); font-family: ui-monospace, Consolas, monospace; white-space: nowrap; }
.bb-help tr:last-child td { border-bottom: 0; }

/* ---------- link / image address dialog ---------- */
.url-box {
  margin: auto; width: min(420px, calc(100vw - 32px)); padding: 22px 24px;
  border: 1px solid var(--border); border-radius: 18px; background: var(--bg-2); color: var(--text);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.4);
}
.url-box::backdrop { background: rgba(10, 10, 14, 0.55); }
.url-box label { display: block; margin-bottom: 8px; font-weight: 700; }
.url-box input {
  width: 100%; height: 46px; padding: 0 14px;
  border-radius: 12px; border: 1px solid var(--border); background: var(--field); color: var(--text);
  font: 15px var(--font); outline: none;
}
.url-box input:focus { border-color: var(--accent); }
.url-error { min-height: 1.3em; margin: 6px 0; color: var(--pink); font-size: 13px; font-weight: 600; }
.url-box form > div { display: flex; justify-content: flex-end; gap: 8px; }
.url-box .btn { width: auto; height: 42px; margin: 0; padding: 0 18px; color: #fff; background: var(--accent); }
.url-box .btn-quiet { background: var(--surface-2); color: var(--text); }

/* ---------- image window: upload or address ---------- */
.img-box {
  width: min(520px, calc(100vw - 32px)); padding: 0; overflow: hidden;
  border: 1px solid var(--border); border-radius: 20px; background: var(--bg-2); color: var(--text);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
}
.img-box[open] { animation: ib-in 0.22s cubic-bezier(0.2, 0.9, 0.3, 1.2); }
.img-box::backdrop { background: rgba(10, 10, 14, 0.55); }
@keyframes ib-in { from { opacity: 0; transform: translateY(10px) scale(0.96); } }

.ib-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 12px 6px 22px; }
.ib-head b { font-size: 16px; }
.ib-close { display: grid; place-items: center; width: 36px; height: 36px; border: 0; border-radius: 10px; background: none; color: var(--muted); cursor: pointer; }
.ib-close:hover { background: var(--surface-2); color: var(--text); }

.ib-tabs { position: relative; display: grid; grid-template-columns: 1fr 1fr; margin: 6px 22px 0; border-bottom: 1px solid var(--border); }
.ib-tabs button {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 42px;
  border: 0; background: none; color: var(--muted); font: 600 14px var(--font); cursor: pointer; transition: color 0.2s;
}
.ib-tabs button:hover, .ib-tabs button[aria-selected="true"] { color: var(--text); }
.ib-tabs .i { width: 16px; height: 16px; }
.ib-tab-line {
  position: absolute; left: 0; bottom: -1px; width: 50%; height: 2px; border-radius: 2px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}
.img-box[data-tab="url"] .ib-tab-line { transform: translateX(100%); }

.ib-pane { padding: 18px 22px 22px; animation: ib-pane 0.25s ease; }
@keyframes ib-pane { from { opacity: 0; transform: translateY(4px); } }
.ib-pane[hidden] { display: none; }

.ib-drop {
  display: grid; justify-items: center; gap: 6px; padding: 30px 20px; text-align: center;
  border: 2px dashed var(--border); border-radius: 16px; background: var(--surface); cursor: pointer;
  transition: border-color 0.2s, background 0.2s, transform 0.2s;
}
.ib-drop:hover, .ib-drop.is-over { border-color: var(--accent); background: rgba(124, 92, 255, 0.08); }
.ib-drop.is-over { transform: scale(1.015); }
.ib-drop[hidden] { display: none; }
.ib-drop-icon { display: grid; place-items: center; width: 52px; height: 52px; margin-bottom: 4px; border-radius: 16px; background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; transition: transform 0.25s; }
.ib-drop-icon .i { width: 24px; height: 24px; }
.ib-drop:hover .ib-drop-icon, .ib-drop.is-over .ib-drop-icon { transform: translateY(-3px); }
.ib-drop b { font-size: 15px; }
.ib-drop u { color: var(--accent-2); text-underline-offset: 3px; }
.ib-drop small { color: var(--muted); font-size: 12.5px; }

.ib-progress { display: flex; align-items: center; gap: 14px; padding: 14px; border: 1px solid var(--border); border-radius: 16px; background: var(--surface); animation: ib-pane 0.25s ease; }
.ib-progress[hidden] { display: none; }
.ib-thumb { flex: none; width: 64px; height: 64px; overflow: hidden; border-radius: 12px; background: var(--surface-2); }
.ib-thumb img { width: 100%; height: 100%; object-fit: cover; }
.ib-info { flex: 1; min-width: 0; display: grid; gap: 7px; }
.ib-row { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; font-size: 13.5px; }
.ib-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.ib-pct { flex: none; font-variant-numeric: tabular-nums; color: var(--accent-2); }
.ib-bar { --p: 0%; position: relative; height: 8px; overflow: hidden; border-radius: 99px; background: var(--surface-2); }
.ib-bar i {
  position: absolute; inset: 0 auto 0 0; width: var(--p); border-radius: inherit;
  background:
    repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.22) 0 8px, transparent 8px 16px),
    linear-gradient(90deg, var(--accent), var(--accent-2));
  background-size: 22px 22px, 100% 100%;
  transition: width 0.25s ease-out, background 0.3s;
  animation: ib-stripes 0.7s linear infinite;
}
@keyframes ib-stripes { to { background-position: 22px 0, 0 0; } }
.is-processing .ib-bar i { animation-duration: 0.35s; }
.is-processing .ib-pct { animation: ib-pulse 1s ease-in-out infinite; }
@keyframes ib-pulse { 50% { opacity: 0.45; } }
.ib-state { color: var(--muted); font-size: 12.5px; }
.is-done .ib-bar i { animation: none; background: var(--green); }
.is-done .ib-pct, .is-done .ib-state { color: var(--green); }
.is-error .ib-bar i { animation: none; background: var(--pink); }
.is-error .ib-pct, .is-error .ib-state { color: var(--pink); }

.ib-url { margin: 0; }
.ib-url label { display: block; margin-bottom: 8px; font-weight: 700; font-size: 14px; }
.ib-url input {
  width: 100%; height: 46px; padding: 0 14px;
  border-radius: 12px; border: 1px solid var(--border); background: var(--field); color: var(--text);
  font: 15px var(--font); outline: none; transition: border-color 0.2s, box-shadow 0.2s;
}
.ib-url input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(124, 92, 255, 0.18); }
.ib-preview { margin: 0 0 12px; padding: 8px; border-radius: 12px; background: var(--surface); text-align: center; animation: ib-pane 0.25s ease; }
.ib-preview[hidden] { display: none; }
.ib-preview img { max-width: 100%; max-height: 200px; border-radius: 8px; }
.ib-foot { display: flex; justify-content: flex-end; gap: 8px; }
.ib-foot .btn { width: auto; height: 42px; margin: 0; padding: 0 18px; color: #fff; background: var(--accent); }
.ib-foot .btn-quiet { background: var(--surface-2); color: var(--text); }

@media (prefers-reduced-motion: reduce) {
  .img-box[open], .ib-pane, .ib-progress, .ib-preview, .ib-bar i { animation: none; }
}

/* ---------- toast ---------- */
.toast {
  position: fixed; z-index: 100; left: 50%; bottom: 24px; max-width: calc(100vw - 32px); margin: 0;
  padding: 12px 18px; border-radius: 14px; background: var(--text); color: var(--bg);
  font-weight: 600; font-size: 14px; box-shadow: 0 12px 30px rgba(0, 0, 0, 0.35);
  opacity: 0; transform: translate(-50%, 12px); pointer-events: none; transition: opacity 0.2s, transform 0.2s;
}
.toast.is-on { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 600px) {
  .composer { padding: 18px 16px; }
  .write-head h1 { font-size: 26px; }
  .tools { top: 66px; }
  .mode-switch { margin-left: 0; }
  .composer-foot .send, .post-act { flex: 1 1 auto; justify-content: center; }
  .composer textarea, .editor { min-height: 200px; }
}
