* {
    box-sizing: border-box;
}

html,
body {
    min-height: 100%;
}

body {
    margin: 0;
    background: #f4f5f7;
    color: #172033;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select,
textarea {
    font: inherit;
}

button,
.file-button {
    min-height: 38px;
    border: 1px solid #c9d1dc;
    background: #fff;
    color: #172033;
    padding: 8px 12px;
    cursor: pointer;
}

button:hover,
.file-button:hover {
    background: #f8fafc;
}

button:disabled {
    cursor: not-allowed;
    opacity: 0.48;
}

a {
    color: #1459a8;
}

.tool-shell {
    width: min(1440px, calc(100vw - 32px));
    margin: 0 auto;
    padding: 24px 0 28px;
}

.tool-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 18px;
}

.eyebrow {
    margin: 0 0 4px;
    color: #667085;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0;
    text-transform: uppercase;
}

h1,
h2 {
    margin: 0;
    letter-spacing: 0;
}

h1 {
    font-size: 2rem;
    line-height: 1.1;
}

h2 {
    font-size: 1rem;
}

.back-link {
    display: inline-flex;
    min-height: 38px;
    align-items: center;
    border: 1px solid #c9d1dc;
    background: #fff;
    padding: 8px 12px;
    text-decoration: none;
}

.toolbar,
.quick-actions {
    display: flex;
    align-items: end;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 10px;
}

.toolbar {
    border: 1px solid #d8dee8;
    background: #fff;
    padding: 12px;
}

.field {
    display: grid;
    gap: 5px;
    min-width: 170px;
}

.field--name {
    min-width: min(320px, 100%);
    flex: 1 1 280px;
}

.field span,
.check-field span {
    color: #667085;
    font-size: 0.78rem;
    font-weight: 700;
}

input,
select,
textarea {
    border: 1px solid #c9d1dc;
    background: #fff;
    color: #172033;
}

input,
select {
    min-height: 38px;
    padding: 7px 10px;
}

.check-field {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 38px;
    padding: 8px 4px;
}

.check-field input {
    min-height: 0;
}

.file-button {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.file-button input {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

.quick-actions button {
    background: #eef4ff;
    border-color: #c7d7fe;
}

.workspace {
    display: grid;
    grid-template-columns: minmax(360px, 0.9fr) minmax(420px, 1.3fr);
    gap: 14px;
    align-items: stretch;
    min-height: min(760px, calc(100vh - 250px));
}

.editor-panel,
.preview-panel {
    display: grid;
    grid-template-rows: auto 1fr;
    min-width: 0;
    border: 1px solid #d8dee8;
    background: #fff;
}

.panel-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    min-height: 54px;
    border-bottom: 1px solid #d8dee8;
    padding: 10px 12px;
}

.button-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-end;
}

#diagram-source {
    width: 100%;
    min-height: 520px;
    height: 100%;
    resize: none;
    border: 0;
    padding: 14px;
    outline: none;
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
    font-size: 0.92rem;
    line-height: 1.45;
    tab-size: 4;
}

.diagram-preview {
    min-height: 520px;
    overflow: auto;
    padding: 18px;
    background: #fbfcfe;
}

.diagram-preview svg {
    display: block;
    max-width: none;
    height: auto;
}

.diagram-preview.is-fit svg {
    max-width: 100%;
}

.empty-state {
    display: grid;
    place-items: center;
    min-height: 300px;
    border: 1px dashed #c9d1dc;
    color: #667085;
    text-align: center;
}

.empty-state--error {
    border-color: #f0b4b4;
    background: #fff7f7;
    color: #a64242;
}

.message {
    min-height: 24px;
    margin: 12px 0 0;
    color: #667085;
    font-size: 0.92rem;
}

.message[data-type="success"] {
    color: #167346;
}

.message[data-type="error"] {
    color: #b42318;
}

.credit {
