:root {
    --bg: #07101c;
    --panel: rgba(10, 20, 33, 0.7);
    --panel-strong: rgba(14, 28, 44, 0.82);
    --line: rgba(173, 201, 232, 0.18);
    --line-strong: rgba(173, 201, 232, 0.28);
    --text: #eaf3ff;
    --muted: #97abc4;
    --blue: #64a5ff;
    --teal: #49d2c7;
    --amber: #f0b35e;
    --rose: #ff8a88;
    --shadow: 0 24px 60px rgba(1, 8, 18, 0.42);
    --radius-xl: 28px;
    --radius-lg: 22px;
    --radius-md: 16px;
    --radius-sm: 12px;
}

* {
    box-sizing: border-box;
}

html,
body {
    min-height: 100%;
}

body {
    margin: 0;
    color: var(--text);
    font-family: 'Manrope', sans-serif;
    background:
        radial-gradient(circle at 14% 18%, rgba(100, 165, 255, 0.24), transparent 20%),
        radial-gradient(circle at 82% 16%, rgba(73, 210, 199, 0.18), transparent 24%),
        radial-gradient(circle at 74% 70%, rgba(240, 179, 94, 0.12), transparent 18%),
        linear-gradient(180deg, #040b14 0%, #07111b 48%, #081420 100%);
}

button,
input,
select,
textarea {
    font: inherit;
}

.docuflow-shell {
    position: relative;
    max-width: 1680px;
    margin: 0 auto;
    padding: 28px;
}

.orb {
    position: fixed;
    border-radius: 999px;
    filter: blur(26px);
    pointer-events: none;
    opacity: 0.9;
}

.orb-a {
    top: 8%;
    left: 4%;
    width: 260px;
    height: 260px;
    background: rgba(100, 165, 255, 0.16);
}

.orb-b {
    top: 22%;
    right: 6%;
    width: 320px;
    height: 320px;
    background: rgba(73, 210, 199, 0.12);
}

.orb-c {
    bottom: 8%;
    right: 22%;
    width: 280px;
    height: 280px;
    background: rgba(240, 179, 94, 0.09);
}

.glass-panel {
    background: var(--panel);
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
}

.page-header {
    display: grid;
    grid-template-columns: 1.6fr 1fr;
    gap: 20px;
    padding: 26px;
    border-radius: var(--radius-xl);
}

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--muted);
    text-decoration: none;
    margin-bottom: 18px;
}

.back-link:hover {
    color: var(--text);
}

.brand-pill,
.eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 7px 12px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--line);
    color: var(--muted);
    font-size: 12px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.brand-copy h1,
.studio-header h2,
.tip-card h3,
.modal-card h3 {
    margin: 14px 0 10px;
    font-family: 'Space Grotesk', sans-serif;
    letter-spacing: -0.04em;
}

.brand-copy h1 {
    font-size: clamp(2rem, 2.8vw, 3.5rem);
    line-height: 1.05;
}

.brand-copy p,
.tiny-copy,
.modal-copy,
.tip-card li,
.snapshot-card span,
.check-row small,
.field-label,
.section-heading,
.document-card p,
.document-meta,
.activity-copy {
    color: var(--muted);
}

.brand-copy p {
    margin: 0;
    max-width: 760px;
    line-height: 1.7;
}

.workspace-link-row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 18px;
}

.workspace-link-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 11px 14px;
    border-radius: 14px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.05);
    color: var(--text);
    text-decoration: none;
    font-weight: 600;
    transition: 0.2s ease;
}

.workspace-link-btn:hover {
    background: rgba(255, 255, 255, 0.09);
    transform: translateY(-1px);
}

.hero-metrics {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
    align-self: stretch;
}

.metric-card {
    padding: 18px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.05);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 128px;
}

.metric-card span,
.metric-card small {
    color: var(--muted);
}

.metric-card strong {
    display: block;
    margin: 10px 0 4px;
    font-size: clamp(1.7rem, 2.4vw, 2.4rem);
    font-family: 'Space Grotesk', sans-serif;
}

.accent-blue {
    box-shadow: inset 0 0 0 1px rgba(100, 165, 255, 0.14);
}

.accent-amber {
    box-shadow: inset 0 0 0 1px rgba(240, 179, 94, 0.14);
}

.accent-teal {
    box-shadow: inset 0 0 0 1px rgba(73, 210, 199, 0.14);
}

.tab-bar {
    display: inline-flex;
    gap: 8px;
    margin: 18px 0;
    padding: 8px;
    border-radius: 999px;
}

.tab-btn {
    appearance: none;
    border: none;
    border-radius: 999px;
    background: transparent;
    color: var(--muted);
    padding: 12px 18px;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    transition: 0.2s ease;
}

.tab-btn:hover,
.tab-btn.active {
    color: var(--text);
    background: rgba(255, 255, 255, 0.08);
}

.glass-subpanel {
    border: 1px solid var(--line);
    border-radius: 22px;
    background: rgba(255, 255, 255, 0.035);
    padding: 18px;
    margin-bottom: 18px;
}

.section-heading-stack {
    display: grid;
    gap: 4px;
}

.rail-title {
    display: block;
    color: var(--text);
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1rem;
}

.mission-card {
    padding: 16px;
    border-radius: 18px;
    border: 1px solid rgba(240, 179, 94, 0.2);
    background: linear-gradient(180deg, rgba(240, 179, 94, 0.12), rgba(255, 255, 255, 0.03));
}

.mission-card p {
    margin: 0 0 14px;
    color: var(--text);
    line-height: 1.7;
}

.mission-points {
    display: grid;
    gap: 8px;
}

.mission-points span {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--muted);
    font-size: 0.85rem;
}

.mission-points i {
    color: #ffd497;
}

.agent-progress {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 999px;
    border: 1px solid rgba(100, 165, 255, 0.24);
    background: rgba(100, 165, 255, 0.08);
    color: #cfe0ff;
    font-size: 12px;
}

.agent-conversation {
    display: grid;
    gap: 12px;
    max-height: 340px;
    overflow-y: auto;
    padding-right: 4px;
}

.chat-led {
    min-height: 360px;
    max-height: 460px;
    padding: 8px 4px 8px 0;
}

.agent-bubble {
    padding: 14px 16px;
    border-radius: 18px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.05);
}

.agent-bubble.agent {
    background: linear-gradient(180deg, rgba(100, 165, 255, 0.14), rgba(255, 255, 255, 0.05));
    border-color: rgba(100, 165, 255, 0.2);
}

.agent-bubble.user {
    background: linear-gradient(180deg, rgba(73, 210, 199, 0.12), rgba(255, 255, 255, 0.04));
    border-color: rgba(73, 210, 199, 0.2);
}

.agent-bubble strong {
    display: block;
    margin-bottom: 6px;
    font-size: 12px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #dbe9ff;
}

.agent-bubble p {
    margin: 0;
    color: var(--text);
    line-height: 1.6;
    font-size: 0.94rem;
}

.agent-input-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    margin-top: 12px;
}

.agent-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin-top: 12px;
}

.prompt-chip-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.studio-header-hero {
    align-items: end;
}

.studio-lead {
    margin: 0;
    max-width: 780px;
    color: var(--muted);
    line-height: 1.7;
}

.composer-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.25fr) minmax(340px, 0.95fr);
    gap: 16px;
    margin-bottom: 18px;
}

.conversation-dock,
.generation-dock {
    margin-bottom: 0;
}

.conversation-dock {
    background: linear-gradient(180deg, rgba(11, 26, 44, 0.82), rgba(255, 255, 255, 0.03));
}

.conversation-dock-head,
.generation-dock-head,
.section-canvas-header {
    display: flex;
    align-items: start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}

.conversation-dock-head strong,
.generation-dock-head strong,
.section-canvas-header strong {
    display: block;
    color: var(--text);
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1rem;
    margin-top: 8px;
}

.generation-dock {
    background: linear-gradient(180deg, rgba(16, 32, 47, 0.82), rgba(255, 255, 255, 0.03));
}

.flow-rack {
    display: grid;
    gap: 12px;
}

.flow-card {
    padding: 16px;
    border-radius: 18px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.04);
}

.flow-card small {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: 0.72rem;
}

.flow-card strong {
    display: block;
    margin: 10px 0 8px;
    color: var(--text);
    font-size: 1.04rem;
}

.flow-card span {
    color: var(--muted);
    line-height: 1.6;
    font-size: 0.88rem;
}

.agent-card {
    background: linear-gradient(180deg, rgba(100, 165, 255, 0.14), rgba(255, 255, 255, 0.03));
}

.chain-card {
    background: linear-gradient(180deg, rgba(240, 179, 94, 0.14), rgba(255, 255, 255, 0.03));
}

.drive-card {
    background: linear-gradient(180deg, rgba(73, 210, 199, 0.14), rgba(255, 255, 255, 0.03));
}

.flow-action-stack {
    display: grid;
    gap: 10px;
    margin-top: 14px;
}

.flow-note {
    margin-top: 14px;
    padding: 12px 14px;
    border-radius: 16px;
    border: 1px solid rgba(100, 165, 255, 0.18);
    background: rgba(255, 255, 255, 0.04);
    color: var(--muted);
    line-height: 1.6;
    font-size: 0.84rem;
    display: flex;
    gap: 8px;
    align-items: start;
}

.flow-note i {
    color: var(--blue);
    margin-top: 2px;
}

.chain-stage {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}

.chain-node {
    position: relative;
    padding: 18px;
    border-radius: 22px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.045);
    overflow: hidden;
}

.chain-node::after {
    content: '';
    position: absolute;
    inset: auto -18% 24px auto;
    width: 120px;
    height: 120px;
    border-radius: 999px;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.14), transparent 70%);
    pointer-events: none;
}

.chain-node.agent-node {
    background: linear-gradient(180deg, rgba(100, 165, 255, 0.14), rgba(255, 255, 255, 0.04));
}

.chain-node.chain-node-center {
    background: linear-gradient(180deg, rgba(240, 179, 94, 0.14), rgba(255, 255, 255, 0.04));
}

.chain-node.drive-node {
    background: linear-gradient(180deg, rgba(73, 210, 199, 0.14), rgba(255, 255, 255, 0.04));
}

.chain-node-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}

.chain-node-head strong {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1rem;
}

.chain-node-head i {
    width: 42px;
    height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.08);
}

.chain-node-status {
    display: block;
    margin-bottom: 8px;
    color: var(--text);
    font-size: 1.02rem;
    font-weight: 700;
}

.chain-node-meta {
    margin: 0;
    color: var(--muted);
    line-height: 1.6;
    font-size: 0.9rem;
    word-break: break-word;
}

.section-canvas {
    display: grid;
    gap: 14px;
}

.stage-shell {
    padding: 18px;
}

.section-header-actions,
.section-card-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.section-title-stack {
    display: grid;
    gap: 6px;
    min-width: 0;
}

.section-status-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.section-order-chip,
.section-ready-chip,
.section-pending-chip {
    display: inline-flex;
    align-items: center;
    min-height: 26px;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.section-order-chip {
    border: 1px solid rgba(173, 201, 232, 0.18);
    background: rgba(255, 255, 255, 0.06);
    color: #d5e6ff;
}

.section-ready-chip {
    border: 1px solid rgba(73, 210, 199, 0.24);
    background: rgba(73, 210, 199, 0.12);
    color: #b5f6ef;
}

.section-pending-chip {
    border: 1px solid rgba(255, 138, 136, 0.28);
    background: rgba(255, 138, 136, 0.12);
    color: #ffd0cf;
}

.canvas-section {
    border-radius: 22px;
    border: 1px solid rgba(173, 201, 232, 0.18);
    background: rgba(255, 255, 255, 0.035);
    overflow: hidden;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.canvas-section.tone-summary {
    border-color: rgba(88, 152, 255, 0.28);
    background: linear-gradient(180deg, rgba(88, 152, 255, 0.12), rgba(255, 255, 255, 0.035));
}

.canvas-section.tone-summary .canvas-section-head,
.canvas-section.tone-summary .section-index {
    background: rgba(88, 152, 255, 0.14);
}

.canvas-section.tone-scope {
    border-color: rgba(73, 210, 199, 0.28);
    background: linear-gradient(180deg, rgba(73, 210, 199, 0.12), rgba(255, 255, 255, 0.035));
}

.canvas-section.tone-scope .canvas-section-head,
.canvas-section.tone-scope .section-index {
    background: rgba(73, 210, 199, 0.14);
}

.canvas-section.tone-commercial {
    border-color: rgba(240, 179, 94, 0.28);
    background: linear-gradient(180deg, rgba(240, 179, 94, 0.12), rgba(255, 255, 255, 0.035));
}

.canvas-section.tone-commercial .canvas-section-head,
.canvas-section.tone-commercial .section-index {
    background: rgba(240, 179, 94, 0.14);
}

.canvas-section.tone-timeline {
    border-color: rgba(185, 132, 255, 0.28);
    background: linear-gradient(180deg, rgba(185, 132, 255, 0.12), rgba(255, 255, 255, 0.035));
}

.canvas-section.tone-timeline .canvas-section-head,
.canvas-section.tone-timeline .section-index {
    background: rgba(185, 132, 255, 0.14);
}

.canvas-section.tone-signatures {
    border-color: rgba(255, 107, 150, 0.28);
    background: linear-gradient(180deg, rgba(255, 107, 150, 0.12), rgba(255, 255, 255, 0.035));
}

.canvas-section.tone-signatures .canvas-section-head,
.canvas-section.tone-signatures .section-index {
    background: rgba(255, 107, 150, 0.14);
}

.canvas-section.tone-custom {
    border-color: rgba(173, 201, 232, 0.2);
    background: linear-gradient(180deg, rgba(173, 201, 232, 0.08), rgba(255, 255, 255, 0.035));
}

.section-needs-attention {
    border-color: rgba(255, 138, 136, 0.36);
}

.canvas-section-head {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 12px;
    align-items: center;
    padding: 14px 16px;
    border-bottom: 1px solid rgba(173, 201, 232, 0.12);
    background: rgba(255, 255, 255, 0.04);
}

.section-index {
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    border: 1px solid rgba(100, 165, 255, 0.28);
    background: rgba(100, 165, 255, 0.1);
    color: #dbe9ff;
    font-size: 12px;
    font-weight: 700;
}

.section-title-input {
    width: 100%;
    border: none;
    outline: none;
    background: transparent;
    color: var(--text);
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1rem;
}

.section-body {
    min-height: 170px;
    padding: 20px 18px;
    outline: none;
    color: var(--text);
    line-height: 1.75;
}

.section-body:focus {
    background: rgba(255, 255, 255, 0.025);
}

.section-body p:first-child {
    margin-top: 0;
}

.section-body h1,
.section-body h2,
.section-body h3 {
    font-family: 'Space Grotesk', sans-serif;
}

.compiled-preview {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(247, 250, 255, 0.98));
    color: #14253b;
}

.compiled-preview .compiled-section + .compiled-section {
    margin-top: 22px;
}

.compiled-preview .compiled-section h1,
.compiled-preview .compiled-section h2,
.compiled-preview .compiled-section h3 {
    color: #132238;
}

.compiled-preview .doc-field {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 180px;
    padding: 10px 12px;
    border-radius: 14px;
    margin: 0 4px;
    background: #eef5ff;
    border: 1px dashed #80b0ff;
    color: #325e94;
}

.compiled-preview .doc-checkbox {
    width: 18px;
    height: 18px;
    accent-color: #2d7ff9;
    vertical-align: middle;
}

.signature-slot-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 14px;
    margin-top: 10px;
}

.signature-slot-card {
    display: grid;
    gap: 10px;
    padding: 14px;
    border-radius: 18px;
    border: 1px solid rgba(100, 165, 255, 0.18);
    background: rgba(255, 255, 255, 0.05);
}

.signature-slot-copy {
    display: grid;
    gap: 4px;
}

.signature-slot-copy strong {
    color: var(--text);
}

.signature-slot-copy span {
    color: var(--muted);
    font-size: 0.82rem;
}

.signature-slot-fields {
    display: grid;
    gap: 10px;
}

.danger-btn {
    color: var(--rose);
}

.danger-btn:hover {
    background: rgba(255, 138, 136, 0.12);
}

.pending-required,
.pending-panel {
    animation: missingPulse 0.6s ease-in-out 0s 4;
}

.pending-required {
    border-color: rgba(255, 138, 136, 0.75) !important;
    box-shadow: 0 0 0 3px rgba(255, 138, 136, 0.12);
}

.pending-panel {
    border-color: rgba(255, 138, 136, 0.75) !important;
    box-shadow: 0 0 0 3px rgba(255, 138, 136, 0.1);
}

@keyframes missingPulse {
    0% {
        transform: translateY(0);
        box-shadow: 0 0 0 0 rgba(255, 138, 136, 0);
    }
    50% {
        transform: translateY(-1px);
        box-shadow: 0 0 0 4px rgba(255, 138, 136, 0.16);
    }
    100% {
        transform: translateY(0);
        box-shadow: 0 0 0 0 rgba(255, 138, 136, 0);
    }
}

.workspace-grid {
    display: grid;
    grid-template-columns: 320px minmax(0, 1fr) 310px;
    gap: 18px;
    align-items: start;
}

.control-rail,
.studio-panel,
.insights-rail {
    border-radius: var(--radius-xl);
}

.control-rail,
.insights-rail {
    padding: 18px;
    position: sticky;
    top: 18px;
}

.rail-section + .rail-section {
    margin-top: 18px;
    padding-top: 18px;
    border-top: 1px solid rgba(173, 201, 232, 0.12);
}

.section-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 14px;
}

.section-heading.compact {
    align-items: center;
}

.field-label {
    display: block;
    margin: 0 0 8px;
    font-size: 13px;
    font-weight: 700;
}

.glass-input {
    width: 100%;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.05);
    color: var(--text);
    border-radius: 14px;
    padding: 13px 14px;
    outline: none;
    transition: border-color 0.2s ease, background 0.2s ease;
}

.glass-input:focus {
    border-color: rgba(100, 165, 255, 0.5);
    background: rgba(255, 255, 255, 0.08);
}

.glass-input::placeholder,
.glass-input option {
    color: #8ea3bc;
}

.glass-textarea {
    resize: vertical;
    min-height: 110px;
}

.field-grid,
.modal-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.compact-textarea {
    min-height: 88px;
}

.check-row {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 12px;
    align-items: start;
    padding: 14px;
    border-radius: 16px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.04);
}

.check-row + .check-row {
    margin-top: 10px;
}

.compact-check-row {
    margin-top: 12px;
}

.check-row input {
    margin-top: 4px;
    accent-color: var(--blue);
}

.check-row strong {
    display: block;
    margin-bottom: 5px;
}

.verification-card,
.version-item {
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.04);
    border-radius: 18px;
}

.verification-card {
    padding: 14px;
    display: grid;
    gap: 12px;
}

.verification-row {
    display: grid;
    gap: 6px;
}

.verification-row small,
.version-item small {
    color: var(--muted);
}

.verification-row strong,
.verification-row span {
    color: var(--text);
}

.verification-row code {
    color: #d7e8ff;
    font-size: 12px;
    word-break: break-all;
    white-space: normal;
    padding: 10px 12px;
    border-radius: 12px;
    background: rgba(3, 11, 23, 0.55);
    border: 1px solid rgba(100, 165, 255, 0.18);
}

.version-timeline {
    display: grid;
    gap: 12px;
}

.version-item {
    padding: 14px;
}

.version-item.current {
    border-color: rgba(100, 165, 255, 0.42);
    box-shadow: inset 0 0 0 1px rgba(100, 165, 255, 0.18);
}

.version-head {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: start;
    margin-bottom: 8px;
}

.version-head strong {
    display: block;
    margin-top: 4px;
}

.version-hashes {
    display: grid;
    gap: 8px;
    margin: 12px 0;
}

.version-chip-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 10px 0 0;
}

.mini-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.07);
    border: 1px solid var(--line);
    color: var(--muted);
    font-size: 12px;
}

.version-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 12px;
}

.ghost-action,
.icon-btn,
.action-btn,
.tool-btn,
.snippet-btn {
    appearance: none;
    border: 1px solid transparent;
    cursor: pointer;
    transition: 0.2s ease;
}

.ghost-action,
.icon-btn,
.tool-btn,
.snippet-btn,
.action-btn.secondary {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text);
    border-color: var(--line);
}

.ghost-action:hover,
.icon-btn:hover,
.tool-btn:hover,
.snippet-btn:hover,
.action-btn.secondary:hover {
    background: rgba(255, 255, 255, 0.1);
}

.ghost-action {
    border-radius: 12px;
    padding: 10px 12px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.ghost-action.wide {
    justify-content: center;
    width: 100%;
}

.left-align {
    justify-content: flex-start;
}

.wrap-actions {
    flex-wrap: wrap;
}

.signer-stack,
.activity-feed,
.document-grid {
    display: grid;
    gap: 12px;
}

.signer-item,
.activity-item,
.document-card {
    border: 1px solid var(--line);
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.05);
}

.template-library-section {
    margin-bottom: 18px;
}

.document-card.template-card {
    background: linear-gradient(180deg, rgba(17, 31, 49, 0.82) 0%, rgba(10, 21, 35, 0.88) 100%);
}

.template-card .document-meta {
    gap: 10px;
}

.template-prompt {
    margin-top: 12px;
    padding: 12px 14px;
    border-radius: 14px;
    border: 1px solid rgba(100, 165, 255, 0.15);
    background: rgba(2, 10, 21, 0.46);
    color: var(--muted);
    line-height: 1.6;
}

.rate-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    width: fit-content;
    padding: 7px 10px;
    border-radius: 999px;
    border: 1px solid rgba(73, 210, 199, 0.22);
    background: rgba(73, 210, 199, 0.08);
    color: #a9f2ea;
    font-size: 12px;
    margin-top: 10px;
}

.signer-item {
    padding: 14px;
}

.signer-head,
.document-head,
.activity-item {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
}

.signer-head strong,
.document-card h3,
.snapshot-card strong {
    display: block;
    font-size: 0.98rem;
}

.signer-head span,
.document-card small,
.snapshot-card small,
.activity-item time,
.document-card p,
.document-meta,
.activity-copy {
    font-size: 0.82rem;
}

.signer-chip,
.tiny-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 10px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.06);
    font-size: 12px;
}

.tiny-badge.muted {
    color: var(--muted);
}

.studio-panel {
    padding: 18px;
}

.studio-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 18px;
}

.studio-header.slim {
    margin-bottom: 16px;
}

.toolbar-group {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.status-tools {
    justify-content: flex-end;
}

.editor-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    padding: 12px;
    border-radius: 18px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.04);
    margin-bottom: 14px;
}

.tool-btn {
    border-radius: 12px;
    padding: 10px 12px;
    display: inline-flex;
    align-items: center;
    gap: 7px;
}

.editor-shell {
    border: 1px solid rgba(173, 201, 232, 0.22);
    border-radius: 26px;
    overflow: hidden;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.03));
}

.editor-meta {
    padding: 14px 18px;
    border-bottom: 1px solid rgba(173, 201, 232, 0.12);
}

.document-content {
    min-height: 720px;
    padding: 38px 44px;
    background: rgba(255, 255, 255, 0.96);
    color: #14253b;
    line-height: 1.8;
    outline: none;
    font-size: 15px;
}

.document-content h1,
.document-content h2,
.document-content h3 {
    font-family: 'Space Grotesk', sans-serif;
    color: #14253b;
}

.document-content .doc-field {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 180px;
    padding: 10px 12px;
    border-radius: 14px;
    margin: 0 4px;
    background: #eef5ff;
    border: 1px dashed #80b0ff;
    color: #325e94;
}

.document-content .doc-field.signature-field {
    min-height: 64px;
}

.document-content .doc-field.text-field {
    justify-content: flex-start;
}

.document-content .doc-checkbox {
    width: 18px;
    height: 18px;
    accent-color: #2d7ff9;
    vertical-align: middle;
}

.action-row {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 16px;
}

.action-btn {
    border-radius: 14px;
    padding: 13px 18px;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
}

.action-btn.primary {
    background: linear-gradient(135deg, #2d7ff9, #55c3ff 120%);
    color: #ffffff;
    box-shadow: 0 14px 30px rgba(45, 127, 249, 0.24);
}

.action-btn.primary:hover {
    transform: translateY(-1px);
}

.snapshot-card,
.tip-card {
    padding: 16px;
    border-radius: 18px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.05);
}

.snapshot-card > div + div,
.snapshot-card > button {
    margin-top: 12px;
}

.activity-item {
    padding: 12px 14px;
    align-items: center;
}

.activity-item i {
    color: var(--teal);
}

.activity-copy {
    flex: 1;
    line-height: 1.5;
}

.document-card {
    padding: 16px;
}

.document-card h3 {
    margin: 0 0 8px;
    font-family: 'Space Grotesk', sans-serif;
}

.document-card p {
    margin: 0 0 12px;
    line-height: 1.6;
}

.document-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 12px;
    margin-bottom: 14px;
}

.document-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.snippet-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

.snippet-btn {
    border-radius: 14px;
    padding: 13px 12px;
    text-align: left;
    font-weight: 700;
}

.save-state {
    padding: 6px 10px;
    border-radius: 999px;
    font-size: 12px;
    border: 1px solid var(--line);
}

.save-state.idle,
.save-state.saving {
    color: var(--muted);
}

.save-state.saved {
    color: var(--teal);
    border-color: rgba(73, 210, 199, 0.26);
}

.save-state.error {
    color: var(--rose);
    border-color: rgba(255, 138, 136, 0.26);
}

.tab-panel {
    display: none;
}

.tab-panel.active {
    display: block;
}

.empty-state {
    padding: 32px 20px;
    border-radius: 18px;
    border: 1px dashed var(--line-strong);
    background: rgba(255, 255, 255, 0.04);
    text-align: center;
    color: var(--muted);
}

.modal-shell {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 28px;
    background: rgba(2, 10, 18, 0.68);
    backdrop-filter: blur(8px);
    z-index: 999;
}

.modal-shell.open {
    display: flex;
}

.modal-card {
    width: min(640px, 100%);
    padding: 22px;
    border-radius: 26px;
    border: 1px solid var(--line-strong);
    background: var(--panel-strong);
    box-shadow: var(--shadow);
}

.signature-card {
    width: min(720px, 100%);
}

.modal-header,
.modal-actions,
.modal-actions.split {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.modal-header {
    margin-bottom: 16px;
}

.modal-actions {
    margin-top: 16px;
}

.modal-actions.split {
    justify-content: flex-end;
}

.modal-grid label span {
    display: block;
    margin-bottom: 8px;
    color: var(--muted);
    font-size: 13px;
}

.icon-btn {
    width: 42px;
    height: 42px;
    border-radius: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.signature-canvas {
    width: 100%;
    margin-top: 12px;
    border-radius: 20px;
    border: 1px dashed rgba(100, 165, 255, 0.34);
    background: rgba(255, 255, 255, 0.96);
    touch-action: none;
}

.toast-host {
    position: fixed;
    right: 24px;
    bottom: 24px;
    display: grid;
    gap: 10px;
    z-index: 1000;
}

.toast {
    min-width: 260px;
    max-width: 360px;
    padding: 14px 16px;
    border-radius: 18px;
    border: 1px solid var(--line);
    background: rgba(8, 18, 30, 0.92);
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 10px;
}

.toast.success i {
    color: var(--teal);
}

.toast.error i {
    color: var(--rose);
}

.toast.info i {
    color: var(--blue);
}

@media (max-width: 1320px) {
    .workspace-grid {
        grid-template-columns: 300px minmax(0, 1fr);
    }

    .insights-rail {
        grid-column: 1 / -1;
        position: static;
    }
}

@media (max-width: 1120px) {
    .page-header {
        grid-template-columns: 1fr;
    }

    .hero-metrics {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .workspace-grid {
        grid-template-columns: 1fr;
    }

    .composer-grid {
        grid-template-columns: 1fr;
    }

    .chain-stage {
        grid-template-columns: 1fr;
    }

    .control-rail,
    .insights-rail {
        position: static;
    }
}

@media (max-width: 760px) {
    .docuflow-shell {
        padding: 14px;
    }

    .hero-metrics,
    .field-grid,
    .modal-grid,
    .snippet-grid,
    .agent-actions {
        grid-template-columns: 1fr;
    }

    .agent-input-row {
        grid-template-columns: 1fr;
    }

    .document-content {
        padding: 24px 20px;
        min-height: 560px;
    }

    .conversation-dock-head,
    .generation-dock-head,
    .section-canvas-header {
        flex-direction: column;
        align-items: stretch;
    }

    .tab-bar {
        width: 100%;
        display: grid;
        grid-template-columns: 1fr;
        border-radius: 24px;
    }

    .tab-btn {
        justify-content: center;
    }

    .studio-header,
    .modal-header,
    .action-row {
        flex-direction: column;
        align-items: stretch;
    }

    .document-actions {
        flex-direction: column;
    }
}