:root {
    color-scheme: dark;
    font-family: Arial, Helvetica, sans-serif;
    background: #123b2a;
    color: #f3f7ef;
    --rune-size: 56px;
}

* {
    box-sizing: border-box;
}

html,
body {
    min-height: 100%;
    margin: 0;
    background: #123b2a;
    color: #f3f7ef;
}

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

button,
select,
.button-link {
    border: 1px solid #666;
    border-radius: 0.45rem;
    background: #1c5139;
    color: #f3f7ef;
}

button,
.button-link {
    cursor: pointer;
    text-decoration: none;
}

button:hover,
button:focus-visible,
select:hover,
select:focus-visible,
.button-link:hover,
.button-link:focus-visible {
    border-color: #f3f7ef;
    background: #286749;
    outline: none;
}

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

.viewer-page {
    min-height: 100vh;
    min-height: 100dvh;
    overflow-x: hidden;
}

.cipher-display {
    --local-rune-size: var(--rune-size);
    color: #f3f7ef;
}

.viewer-display {
    min-height: 100vh;
    min-height: 100dvh;
    padding: 1.2rem 1.2rem 6rem;
}

.cipher-line {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    min-height: calc(var(--local-rune-size) * 1.25);
    margin-bottom: calc(var(--local-rune-size) * 0.14);
}

.cipher-word {
    display: inline-flex;
    align-items: center;
    flex: 0 0 auto;
    gap: calc(var(--local-rune-size) * 0.012);
}

.cipher-space {
    display: inline-block;
    flex: 0 0 calc(var(--local-rune-size) * 0.38);
    width: calc(var(--local-rune-size) * 0.38);
}

.rune-token {
    display: block;
    width: auto;
    height: var(--local-rune-size);
    max-width: calc(var(--local-rune-size) * 1.15);
    object-fit: contain;
    user-select: none;
}

.literal-token {
    display: inline-flex;
    align-items: center;
    height: var(--local-rune-size);
    padding: 0 calc(var(--local-rune-size) * 0.08);
    font-size: calc(var(--local-rune-size) * 0.68);
    line-height: 1;
    color: #f3f7ef;
}

.viewer-controls {
    position: fixed;
    right: max(0.75rem, env(safe-area-inset-right));
    bottom: max(0.75rem, env(safe-area-inset-bottom));
    display: flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.45rem;
    border: 1px solid #7aa98c;
    border-radius: 0.6rem;
    background: rgba(18, 59, 42, 0.94);
    box-shadow: 0 0.2rem 1rem rgba(4, 24, 15, 0.55);
}

.viewer-controls button {
    min-width: 3rem;
    min-height: 2.8rem;
    padding: 0.45rem 0.8rem;
    font-weight: 700;
}

.size-label {
    min-width: 3.6rem;
    text-align: center;
    font-size: 0.9rem;
    color: #ddd;
}

.connection-status {
    min-width: 6.5rem;
    padding: 0 0.4rem;
    font-size: 0.9rem;
    color: #bbb;
}

.connection-status.connected {
    color: #b9ffb9;
}

.connection-status.disconnected {
    color: #ffb8b8;
}

.loading-text,
.empty-text {
    color: #aaa;
}

.editor-page {
    min-height: 100vh;
    padding: 1rem;
}

.editor-card {
    width: min(1180px, 100%);
    margin: 0 auto;
}

.narrow-card {
    width: min(480px, 100%);
    padding-top: 8vh;
}

.editor-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 1rem;
}

.editor-header h1,
.narrow-card h1 {
    margin: 0 0 0.35rem;
}

.editor-header p {
    margin: 0;
    color: #bbb;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.header-actions form {
    margin: 0;
}

.panel {
    margin: 1rem 0;
    padding: 1rem;
    border: 1px solid #4f7d61;
    border-radius: 0.65rem;
    background: #164631;
}

.panel h2 {
    margin-top: 0;
    font-size: 1.2rem;
}

label {
    display: block;
    margin: 0 0 0.4rem;
    font-weight: 700;
}

input[type="password"],
select,
textarea {
    border: 1px solid #666;
    border-radius: 0.45rem;
    background: #0d2f20;
    color: #f3f7ef;
}

input[type="password"] {
    width: 100%;
    margin-bottom: 1rem;
    padding: 0.75rem;
}

select {
    min-width: 5rem;
    padding: 0.7rem;
    font-size: 1.1rem;
    font-weight: 700;
}

textarea {
    width: 100%;
    min-height: 10rem;
    resize: vertical;
    padding: 0.85rem;
    line-height: 1.4;
}

input[type="password"]:focus,
textarea:focus {
    border-color: #f3f7ef;
    outline: 2px solid #777;
    outline-offset: 1px;
}

.anchor-controls {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    flex-wrap: wrap;
}

.anchor-controls label {
    margin: 0;
}

.equals-sign {
    font-size: 1.7rem;
    font-weight: 700;
}

.selected-rune-summary {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    color: #ddd;
}

.selected-rune-summary img {
    width: 64px;
    height: 64px;
    object-fit: contain;
}

.help-text {
    color: #aaa;
    font-size: 0.92rem;
}

.rune-chooser {
    display: grid;
    grid-template-columns: repeat(10, minmax(56px, 1fr));
    gap: 0.5rem;
    margin-top: 0.8rem;
}

.rune-choice {
    aspect-ratio: 1;
    min-width: 0;
    padding: 0.35rem;
}

.rune-choice img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    pointer-events: none;
}

.rune-choice.selected {
    border: 3px solid #fff;
    background: #2c7250;
}

.mapping-details {
    margin-top: 1rem;
}

.mapping-details summary {
    cursor: pointer;
    color: #ddd;
}

.mapping-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(120px, 1fr));
    gap: 0.5rem;
    margin-top: 0.8rem;
}

.mapping-cell {
    display: grid;
    grid-template-columns: 1.4rem 1rem 54px;
    align-items: center;
    justify-content: center;
    gap: 0.3rem;
    min-height: 64px;
    padding: 0.35rem;
    border: 1px solid #4f7d61;
    border-radius: 0.4rem;
}

.mapping-cell img {
    width: 54px;
    height: 54px;
    object-fit: contain;
}

.mapping-letter {
    font-weight: 700;
    font-size: 1.05rem;
}

.conversion-row {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    flex-wrap: wrap;
    margin: 0.65rem 0 1rem;
}

.textarea-status {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    margin-top: 0.4rem;
    color: #aaa;
    font-size: 0.9rem;
}

.validation-message {
    color: #b9ffb9;
}

.error-text {
    color: #ffb8b8;
}

.editor-preview {
    --local-rune-size: 64px;
    min-height: 130px;
    max-height: 440px;
    overflow: auto;
    padding: 0.8rem;
    border: 1px solid #4f7d61;
    border-radius: 0.45rem;
    background: #123b2a;
}

.primary-button,
.secondary-button,
.button-link {
    min-height: 2.7rem;
    padding: 0.65rem 1rem;
}

.primary-button {
    background: #dcebdc;
    color: #102b1f;
    border-color: #f3f7ef;
    font-weight: 700;
}

.primary-button:hover,
.primary-button:focus-visible {
    background: #c7ddc9;
    color: #102b1f;
}

.large-button {
    min-width: 220px;
    min-height: 3.2rem;
}

.publish-row {
    display: flex;
    justify-content: flex-end;
    margin: 1rem 0 2rem;
}

.message {
    margin: 0.75rem 0;
    padding: 0.75rem;
    border: 1px solid #666;
    border-radius: 0.45rem;
}

.message.success {
    border-color: #6ca96c;
}

.message.error {
    border-color: #b96969;
}

.secondary-link {
    margin-top: 1rem;
}

a {
    color: #f3f7ef;
}

@media (max-width: 850px) {
    .rune-chooser {
        grid-template-columns: repeat(5, minmax(54px, 1fr));
    }

    .mapping-grid {
        grid-template-columns: repeat(2, minmax(120px, 1fr));
    }
}

@media (max-width: 700px) {
    .editor-header {
        flex-direction: column;
    }

    .header-actions {
        width: 100%;
        flex-wrap: wrap;
    }

    .viewer-display {
        padding-left: 0.8rem;
        padding-right: 0.8rem;
    }

    .viewer-controls {
        left: max(0.5rem, env(safe-area-inset-left));
        right: max(0.5rem, env(safe-area-inset-right));
        justify-content: center;
    }

    .connection-status {
        min-width: 0;
    }

    .textarea-status {
        flex-direction: column;
        gap: 0.25rem;
    }
}


/* Green visual identity for the cipher application. */
html,
body,
.viewer-page,
.editor-page {
    background: #123b2a;
    color: #f3f7ef;
}

.panel {
    background: #164631;
    border-color: #4f7d61;
}

.editor-preview {
    background: #0d2f20;
    border-color: #4f7d61;
}

.rune-choice,
.mapping-cell {
    background: #123b2a;
    border-color: #4f7d61;
}

.rune-choice:hover,
.rune-choice:focus-visible {
    background: #1f5b40;
}

.rune-choice.selected {
    border-color: #f3f7ef;
    background: #2c7250;
}

.message.success {
    background: #1c5139;
}

.message.error {
    background: #5a2929;
}

.viewer-display {
    background: #123b2a;
}

.rune-token {
    flex: 0 0 auto;
}
