:root {
    --bg-top: #f8faf9;
    --bg-bottom: #e4eef0;
    --surface: rgba(250, 252, 252, 0.9);
    --surface-strong: #ffffff;
    --surface-muted: #edf4f5;
    --border: rgba(0, 79, 98, 0.14);
    --text: #17323a;
    --text-soft: #4f6771;
    --accent: #004f62;
    --accent-strong: #1f93b4;
    --accent-soft: rgba(31, 147, 180, 0.12);
    --danger: #8e3b32;
    --shadow-lg: 0 24px 70px rgba(0, 79, 98, 0.14);
    --shadow-md: 0 14px 34px rgba(0, 79, 98, 0.1);
    --shadow-sm: 0 8px 20px rgba(0, 79, 98, 0.08);
    --radius-xl: 28px;
    --radius-lg: 20px;
    --radius-md: 14px;
    --radius-sm: 10px;
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    min-height: 100vh;
    padding: 32px 20px 56px;
    font-family: "Segoe UI", "Trebuchet MS", sans-serif;
    color: var(--text);
    background:
        radial-gradient(circle at top left, rgba(31, 147, 180, 0.14), transparent 30%),
        radial-gradient(circle at top right, rgba(0, 79, 98, 0.16), transparent 28%),
        linear-gradient(180deg, var(--bg-top), var(--bg-bottom));
}

a {
    color: var(--accent);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

button,
input,
textarea {
    font: inherit;
}

code {
    display: inline-block;
    padding: 3px 7px;
    border-radius: 8px;
    background: rgba(0, 79, 98, 0.08);
    color: #1b4d5d;
    font-size: 0.92em;
}

.app-shell {
    width: 100%;
    margin: 0 auto;
    display: grid;
    gap: 22px;
}

.hero-card,
.mode-switch,
.tool-panel,
.chat-panel,
.info-grid > section,
#formula-hints,
.tool-stage__frame,
.qr-dialog__card {
    background: var(--surface);
    backdrop-filter: blur(14px);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
}

.hero-card {
    display: grid;
    grid-template-columns: minmax(0, 1.5fr) minmax(260px, 320px);
    gap: 20px;
    padding: 28px;
    border-radius: var(--radius-xl);
    align-items: center;
}

.eyebrow,
.section-label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    width: fit-content;
    padding: 7px 12px;
    border-radius: 999px;
    background: var(--accent-soft);
    color: var(--accent);
    font-size: 0.82rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.hero-card h1 {
    margin: 14px 0 10px;
    font-size: clamp(2rem, 5vw, 3.4rem);
    line-height: 0.95;
    letter-spacing: -0.04em;
}

.hero-card p {
    margin: 0;
    max-width: 60ch;
    color: var(--text-soft);
    line-height: 1.6;
}

.hero-notes {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 18px;
}

.hero-notes span {
    padding: 9px 12px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.72);
    border: 1px solid rgba(0, 79, 98, 0.1);
    color: var(--text-soft);
    font-size: 0.92rem;
}

.hero-panel,
.chat-sidecard {
    padding: 18px;
    border-radius: 22px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(232, 241, 242, 0.92));
    border: 1px solid rgba(0, 79, 98, 0.1);
    box-shadow: var(--shadow-md);
}

.hero-panel strong,
.workspace-heading h2,
.chat-toolbar h2 {
    margin: 0;
}

.hero-panel strong {
    display: block;
    margin-bottom: 10px;
    color: var(--accent);
    font-size: 0.86rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.mode-switch {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    border-radius: var(--radius-lg);
    flex-wrap: wrap;
}

.mode-button {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    min-height: 44px;
    padding: 0 16px;
    border-radius: 999px;
    border: 1px solid rgba(0, 79, 98, 0.14);
    background: rgba(255, 255, 255, 0.7);
    color: var(--text-soft);
    cursor: pointer;
    transition: transform 0.18s ease, border-color 0.18s ease, background-color 0.18s ease, color 0.18s ease;
}

.mode-button:is(a) {
    text-decoration: none;
}

.mode-button:hover {
    transform: translateY(-1px);
    border-color: rgba(31, 147, 180, 0.3);
    background: rgba(255, 255, 255, 0.95);
}

.mode-button.is-active {
    color: #fffdf9;
    background: linear-gradient(135deg, var(--accent), var(--accent-strong));
    border-color: transparent;
    box-shadow: 0 12px 26px rgba(0, 79, 98, 0.22);
}

.mode-hint {
    color: var(--text-soft);
    font-size: 0.92rem;
}

.help-shell {
    gap: 22px;
}

.help-hero,
.help-logbook {
    padding: 28px;
}

.help-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
}

.help-card,
.log-entry {
    border: 1px solid rgba(0, 79, 98, 0.1);
    border-radius: calc(var(--radius-lg) - 4px);
    background: rgba(255, 255, 255, 0.72);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

.help-card {
    padding: 20px;
}

.help-card h2,
.log-entry h3 {
    margin: 0 0 10px;
    color: var(--text);
}

.help-card p,
.log-entry p {
    margin: 0;
    color: var(--text-soft);
    line-height: 1.6;
}

.help-card p + p,
.log-entry p + p {
    margin-top: 10px;
}

.logbook-list {
    display: grid;
    gap: 14px;
}

.log-entry {
    padding: 18px 20px;
}

.log-entry__meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
    color: var(--text-soft);
    font-size: 0.92rem;
}

.log-entry__version {
    display: inline-flex;
    align-items: center;
    min-height: 30px;
    padding: 0 10px;
    border-radius: 999px;
    background: rgba(31, 147, 180, 0.12);
    color: var(--accent);
    font-weight: 700;
}

.workspace-shell {
    display: grid;
    gap: 20px;
    align-items: start;
    grid-template-columns: 1fr;
}

.desktop-window-dragging {
    user-select: none;
}

.tool-panel,
.chat-panel {
    border-radius: var(--radius-xl);
    padding: 24px;
    transition: transform 0.22s ease, box-shadow 0.22s ease, border-color 0.22s ease, opacity 0.22s ease;
}

.workspace-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
}

.workspace-heading h2 {
    margin: 10px 0 6px;
    font-size: 1.28rem;
}

.workspace-heading p {
    margin: 0;
    color: var(--text-soft);
    line-height: 1.55;
}

.workspace-badge,
.status-chip {
    padding: 10px 14px;
    border-radius: 999px;
    background: var(--surface-muted);
    border: 1px solid var(--border);
    color: var(--text-soft);
    white-space: nowrap;
    font-size: 0.92rem;
}

body[data-mode="tafel"] .tool-panel {
    border: 2px solid rgba(0, 79, 98, 0.34);
    box-shadow:
        0 0 0 1px rgba(0, 79, 98, 0.08),
        var(--shadow-lg);
}

body[data-mode="tafel"] .chat-panel {
    opacity: 0.96;
    background:
        linear-gradient(180deg, var(--chat-panel-top), var(--chat-panel-bottom));
}

body[data-mode="tafel"][data-desktop-layout="floating"] {
    overflow: hidden;
}

body[data-mode="tafel"][data-desktop-layout="floating"] .workspace-shell {
    position: relative;
    min-height: calc(100vh - 132px);
    display: block;
}

body[data-mode="tafel"][data-desktop-layout="floating"] .tool-panel,
body[data-mode="tafel"][data-desktop-layout="floating"] .chat-panel {
    position: fixed;
    margin: 0;
    resize: both;
    overflow: auto;
    min-width: 360px;
    min-height: 260px;
    max-width: calc(100vw - 32px);
    max-height: calc(100vh - 100px);
    backdrop-filter: blur(18px);
}

body[data-mode="tafel"][data-desktop-layout="floating"] .workspace-heading {
    cursor: move;
    position: sticky;
    top: 0;
    z-index: 3;
    padding-bottom: 12px;
    background: inherit;
}

body[data-mode="tafel"][data-desktop-layout="floating"] .workspace-heading button,
body[data-mode="tafel"][data-desktop-layout="floating"] .workspace-heading a,
body[data-mode="tafel"][data-desktop-layout="floating"] .workspace-heading input,
body[data-mode="tafel"][data-desktop-layout="floating"] .workspace-heading textarea,
body[data-mode="tafel"][data-desktop-layout="floating"] .workspace-heading label {
    cursor: auto;
}

body[data-mode="tafel"][data-desktop-layout="floating"] .tool-panel.is-dragging,
body[data-mode="tafel"][data-desktop-layout="floating"] .chat-panel.is-dragging {
    box-shadow: 0 26px 80px rgba(0, 79, 98, 0.24);
}

body[data-mode="tafel"][data-desktop-layout="floating"] .tool-stage,
body[data-mode="tafel"][data-desktop-layout="floating"] .chat-layout,
body[data-mode="tafel"][data-desktop-layout="floating"] .chat-main {
    min-height: 0;
}

body[data-mode="tafel"][data-desktop-layout="floating"] .tool-panel {
    display: grid;
    grid-template-rows: auto 1fr;
}

body[data-mode="tafel"][data-desktop-layout="floating"] .tool-stage__frame,
body[data-mode="tafel"][data-desktop-layout="floating"] .tool-stage__frame--editor {
    min-height: 100%;
    height: 100%;
}

body[data-mode="tafel"][data-desktop-layout="floating"] .chat-panel {
    display: grid;
    grid-template-rows: auto 1fr;
}

body[data-mode="tafel"][data-desktop-layout="floating"] .chat-layout {
    height: 100%;
    grid-template-columns: 1fr;
}

body[data-mode="tafel"][data-desktop-layout="floating"] .chat-sidecard {
    display: none;
}

body[data-mode="tafel"][data-desktop-layout="floating"] #chat-messages {
    max-height: none;
    height: 100%;
}

body[data-mode="smartphone"] .tool-panel {
    display: none;
}

body[data-mode="smartphone"] .chat-panel {
    border: 2px solid rgba(0, 79, 98, 0.34);
    box-shadow:
        0 0 0 1px rgba(0, 79, 98, 0.08),
        var(--shadow-lg);
    background:
        linear-gradient(180deg, #f9fcff, #ebf3ff);
}

body[data-mode="smartphone"] .chat-panel .workspace-heading h2,
body[data-mode="smartphone"] .chat-panel .workspace-heading p,
body[data-mode="smartphone"] .chat-panel .section-label,
body[data-mode="smartphone"] .chat-sidecard,
body[data-mode="smartphone"] .info-grid,
body[data-mode="smartphone"] .chat-insert-button,
body[data-mode="smartphone"] .char-counter {
    display: none;
}

body[data-mode="smartphone"] .workspace-shell {
    gap: 0;
}

body[data-mode="smartphone"] .chat-panel {
    min-height: calc(100vh - 132px);
    display: grid;
    grid-template-rows: auto 1fr;
    padding-bottom: 16px;
}

body[data-mode="smartphone"] .workspace-heading {
    margin-bottom: 12px;
    align-items: center;
}

body[data-mode="smartphone"] .status-chip {
    margin-left: auto;
}

body[data-mode="smartphone"] .chat-layout,
body[data-mode="smartphone"] .chat-main {
    min-height: 0;
    height: 100%;
}

body[data-mode="smartphone"] .chat-layout {
    display: block;
}

body[data-mode="smartphone"] .chat-main {
    grid-template-rows: auto auto 1fr;
    gap: 10px;
}

body[data-mode="smartphone"] #chat-input {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
    margin-bottom: 12px;
    position: sticky;
    top: 0;
    z-index: 4;
    padding: 10px 0 12px;
    background: linear-gradient(180deg, #f9fcff 0%, #f9fcff 78%, rgba(249, 252, 255, 0.3) 100%);
}

body[data-mode="smartphone"] .composer-menu {
    position: sticky;
    top: 0;
    z-index: 5;
    padding: 8px;
    background: linear-gradient(180deg, #f9fcff 0%, #f9fcff 82%, rgba(249, 252, 255, 0.36) 100%);
}

body[data-mode="smartphone"] .composer-actions {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    justify-content: stretch;
}

body[data-mode="smartphone"] .mini-button--icon {
    width: 100%;
    min-width: 0;
    min-height: 48px;
}

body[data-mode="smartphone"] .message-row {
    grid-template-columns: 1fr auto;
    align-items: stretch;
}

body[data-mode="smartphone"] #message {
    min-height: 132px;
    font-size: 1rem;
    border-radius: 18px;
}

body[data-mode="smartphone"] .composer-meta input[type="text"] {
    min-height: 50px;
}

body[data-mode="smartphone"] #chat-messages {
    min-height: 0;
    height: 100%;
    max-height: none;
    padding: 12px;
}

.button-icon,
.label-icon {
    width: 20px;
    height: 20px;
    flex: 0 0 auto;
}

.label-icon {
    width: 18px;
    height: 18px;
}

.tool-stage {
    width: 100%;
}

.tool-stage__frame {
    width: 100%;
    min-height: 520px;
    border-radius: var(--radius-xl);
    background: rgba(255, 255, 255, 0.82);
}

.tool-stage__frame--editor {
    height: min(88vh, 1120px);
}

.chat-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 240px;
    gap: 18px;
    align-items: start;
}

.chat-main {
    display: grid;
    gap: 18px;
}

#chat-input {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
    align-items: start;
}

.composer-meta {
    display: grid;
    gap: 8px;
}

.input-label,
.sidecard-label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--accent);
    font-size: 0.82rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

#chat-input input[type="text"],
#chat-input textarea {
    width: 100%;
    min-height: 54px;
    padding: 14px 16px;
    border: 1px solid rgba(0, 79, 98, 0.14);
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.9);
    color: var(--text);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.45);
    transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

#chat-input input[type="text"]:focus,
#chat-input textarea:focus {
    outline: none;
    border-color: rgba(31, 147, 180, 0.5);
    box-shadow: 0 0 0 4px rgba(31, 147, 180, 0.14);
    transform: translateY(-1px);
}

#chat-input textarea {
    min-height: 96px;
    resize: vertical;
    line-height: 1.5;
}

.message-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    align-items: stretch;
}

.message-send-button {
    align-self: stretch;
    width: 52px;
    min-width: 52px;
    min-height: 100%;
    border-radius: 16px;
}

.composer-actions {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.mini-button {
    min-height: 34px;
    padding: 0 10px;
    border-radius: 999px;
    border: 1px solid rgba(0, 79, 98, 0.14);
    background: rgba(255, 255, 255, 0.74);
    color: var(--text-soft);
    cursor: pointer;
    transition: transform 0.18s ease, background-color 0.18s ease, border-color 0.18s ease;
}

.mini-button--icon {
    width: 36px;
    min-width: 36px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.mini-button--icon img {
    width: 16px;
    height: 16px;
}

.mini-button--accent {
    background: linear-gradient(135deg, var(--accent), var(--accent-strong));
    border-color: transparent;
    box-shadow: 0 8px 18px rgba(0, 79, 98, 0.18);
}

.mini-button--accent img {
    filter: brightness(0) invert(1);
}

.mini-button--danger {
    background: rgba(142, 59, 50, 0.08);
    border-color: rgba(142, 59, 50, 0.16);
}

.mini-button:hover {
    transform: translateY(-1px);
    background: rgba(255, 255, 255, 0.95);
    border-color: rgba(31, 147, 180, 0.28);
}

.mini-button--accent:hover {
    background: linear-gradient(135deg, var(--accent), var(--accent-strong));
    border-color: transparent;
}

.mini-button--danger:hover {
    background: rgba(142, 59, 50, 0.14);
    border-color: rgba(142, 59, 50, 0.24);
}

.char-counter {
    color: var(--text-soft);
    font-size: 0.82rem;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.char-counter.is-warning {
    color: var(--accent-strong);
}

.char-counter.is-limit {
    color: var(--danger);
    font-weight: 700;
}

#chat-messages {
    min-height: 360px;
    max-height: 560px;
    overflow-y: auto;
    padding: 16px;
    border-radius: 20px;
    background:
        linear-gradient(180deg, var(--chat-stream-top), var(--chat-stream-bottom)),
        repeating-linear-gradient(
            180deg,
            rgba(37, 99, 235, 0.028) 0,
            rgba(37, 99, 235, 0.028) 28px,
            transparent 28px,
            transparent 56px
        );
    border: 1px solid rgba(0, 79, 98, 0.1);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

.chat-message {
    margin-bottom: 8px;
    padding: 10px 12px;
    border-radius: 14px;
    background: var(--chat-message-bg);
    border: 1px solid var(--chat-message-border);
    box-shadow: var(--chat-message-shadow);
    line-height: 1.45;
}

.chat-message__body {
    display: grid;
    gap: 6px;
    min-width: 0;
}

.reply-banner {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.72);
    border: 1px solid rgba(0, 79, 98, 0.12);
}

.reply-banner__meta {
    min-width: 0;
    display: grid;
    gap: 2px;
    min-height: 36px;
    align-content: center;
}

.reply-banner__meta strong {
    font-size: 0.86rem;
    color: var(--accent);
}

.reply-banner__meta span {
    min-width: 0;
    color: var(--text-soft);
    font-size: 0.84rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.reply-banner:not(.is-active) .reply-banner__meta strong,
.reply-banner:not(.is-active) .reply-banner__meta span {
    visibility: hidden;
}

.reply-banner__actions {
    justify-content: flex-end;
    flex-wrap: nowrap;
}

.reply-banner__close {
    flex: 0 0 auto;
}

.new-messages-jump {
    position: sticky;
    bottom: 14px;
    margin: 0 auto;
    min-height: 42px;
    padding: 0 16px;
    border-radius: 999px;
    border: 0;
    background: linear-gradient(135deg, var(--accent), var(--accent-strong));
    color: #fffdf9;
    font-weight: 700;
    box-shadow: 0 14px 28px rgba(0, 79, 98, 0.22);
    cursor: pointer;
    z-index: 4;
}

.chat-message__meta {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 30px;
    padding: 2px 0;
    flex-wrap: wrap;
}

.chat-message__time,
.chat-message__name {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    padding: 0 9px;
    border-radius: 999px;
    border: 1px solid transparent;
    font-size: 0.78rem;
    font-weight: 700;
}

.chat-message__time {
    background: var(--chat-meta-bg);
    color: var(--text-soft);
    border-color: rgba(53, 92, 125, 0.1);
}

.chat-message__name {
    border-color: rgba(37, 99, 235, 0.2);
}

.chat-message__text {
    min-width: 0;
    color: var(--text);
    word-break: break-word;
    font-size: 0.96rem;
}

.chat-message__text a {
    font-weight: 600;
}

.chat-message__actions {
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.chat-copy-button {
    flex: 0 0 auto;
    width: 28px;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    border: 1px solid var(--chat-copy-border);
    background: var(--chat-copy-bg);
    color: var(--text-soft);
    cursor: pointer;
    transition: transform 0.18s ease, background-color 0.18s ease, border-color 0.18s ease;
}

.chat-copy-button:hover {
    transform: translateY(-1px);
    background: var(--chat-copy-hover);
    border-color: rgba(37, 99, 235, 0.24);
}

.chat-copy-button.is-copied {
    background: rgba(15, 118, 110, 0.12);
    border-color: rgba(15, 118, 110, 0.26);
}

.chat-copy-button img {
    width: 15px;
    height: 15px;
}

.chat-copy-button--text {
    width: auto;
    min-width: 74px;
    padding: 0 9px;
    font-size: 0.74rem;
    font-weight: 700;
    white-space: nowrap;
}

.qr-button {
    width: 100%;
    display: grid;
    gap: 12px;
    padding: 0;
    border: 0;
    background: transparent;
    cursor: zoom-in;
    text-align: left;
}

.qr-button img {
    width: 100%;
    display: block;
    border-radius: 18px;
    box-shadow: var(--shadow-sm);
}

.qr-button strong {
    font-size: 1rem;
}

.qr-button span,
.sidecard-copy,
.info-grid p,
.info-grid li,
#formula-hints p,
#formula-hints li,
.qr-dialog__card p {
    color: var(--text-soft);
    line-height: 1.6;
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 18px;
}

.info-grid > section,
#formula-hints {
    border-radius: var(--radius-xl);
    padding: 22px;
}

.info-grid h3,
#formula-hints h3 {
    margin: 10px 0 14px;
    font-size: 1.05rem;
}

.info-grid ul,
#formula-hints ul {
    margin: 0;
    padding-left: 18px;
}

.info-grid .link-list {
    list-style: none;
    padding: 0;
    display: grid;
    gap: 10px;
}

.info-grid .link-list li {
    padding: 11px 12px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.66);
    border: 1px solid rgba(0, 79, 98, 0.08);
}

.qr-dialog {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(19, 24, 29, 0.72);
    z-index: 50;
}

.qr-dialog[aria-hidden="false"] {
    display: flex;
}

.qr-dialog__card {
    width: min(92vw, 560px);
    padding: 22px;
    border-radius: 30px;
    text-align: center;
}

.qr-dialog__card img {
    width: 100%;
    display: block;
    border-radius: 22px;
}

.qr-dialog__card h3 {
    margin: 14px 0 6px;
    font-size: 1.25rem;
}

.qr-close {
    margin-top: 18px;
    min-height: 48px;
    padding: 0 16px;
    border-radius: 999px;
    border: 0;
    background: var(--text);
    color: #fff;
    cursor: pointer;
}

@media (max-width: 1100px) {
    .hero-card,
    .info-grid {
        grid-template-columns: 1fr;
    }

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

@media (max-width: 860px) {
    #chat-input {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 680px) {
    body {
        padding: 18px 12px 36px;
    }

    .hero-card,
    .tool-panel,
    .chat-panel,
    .info-grid > section,
    #formula-hints,
    .mode-switch {
        padding: 18px;
    }

    .workspace-heading,
    .mode-switch {
        flex-direction: column;
        align-items: flex-start;
    }

    body[data-mode="smartphone"] .workspace-heading {
        flex-direction: row;
        align-items: center;
    }

    body[data-mode="smartphone"] #chat-input {
        padding-top: 6px;
    }

    #chat-input {
        grid-template-columns: 1fr;
    }

    .reply-banner {
        grid-template-columns: 1fr;
        align-items: flex-start;
    }

    .message-row {
        grid-template-columns: 1fr;
    }

    .message-send-button {
        width: 100%;
        min-width: 0;
        min-height: 46px;
    }

    #chat-messages {
        min-height: 300px;
    }

    .chat-message {
        padding: 9px 10px;
    }

    .chat-copy-button {
        width: 28px;
        height: 28px;
    }

    .chat-message__actions {
        width: 100%;
        margin-left: 0;
        justify-content: flex-end;
    }

    .tool-stage__frame,
    .tool-stage__frame--editor {
        min-height: 420px;
        height: 420px;
    }
}
