body {
    background-color: var(--bg);
    font-family: "Manrope", sans-serif;
}

.main {
    position: absolute;
    top: 130px;
    width: 50%;
    left: 50%;
    transform: translateX(-50%);
}

.upbar {
    position: absolute;
    left: 0px;
    width: 100%;
    top: 0px;
    height: 80px;
    border-bottom: 1px solid var(--line);
}

.upbar > .content {
    position: absolute;
    display: inline-block;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 80%;
}

.upbar > .content > * {
    position: relative;
    display: inline-block;
    vertical-align: middle;
}

.upbar > .content > .logo {
    color: var(--text);
    font-size: 115%;
}

.upbar > .content > .logo > .accent {
    display: inline-block;
    position: relative;
    color: var(--accent);
    transform: translateY(10%);
    padding-right: 5px;
}

.upbar > .content > .right {
    position: absolute;
    right: 0px;
}

.upbar > .content > .right > * {
    display: inline-block;
    position: relative;
    vertical-align: middle;
}

.upbar > .content > .right > button:hover {
    transition: 0.2s;
    -webkit-transition: 0.2s;
    opacity: 0.8;
}

.upbar > .content > .right > button#main-action-btn {
    transition: 0.2s;
    -webkit-transition: 0.2s;
    margin-right: 10px;
    width: 120px;
    height: 30px;
    cursor: pointer;
    border-radius: 15px;
    background-color: var(--accent);
    border: 1.5px solid var(--accent-strong);
    color: var(--bg);
}

body.read-only .story-actions,
body.read-only .editor-toolbar,
body.read-only .image-size-panel,
body.read-only .image-resize-handle {
    display: none !important;
}

body.read-only .editor {
    caret-color: transparent;
}

.upbar > .content > .right > button#theme {
    transition: 0.2s;
    -webkit-transition: 0.2s;
    margin-right: 10px;
    height: 30px;
    box-sizing: 1/1;
    text-align: center;
    background-color: rgba(0, 0, 0, 0);
    border: none;
    margin-top: 4px;
    padding-right: 15px;
    color: var(--text);
    cursor: pointer;
}

.upbar > .content > .right > button#theme:hover {
    transition: 0.2s;
    -webkit-transition: 0.2s;
    color: var(--accent);
}

input#title {
    position: relative;
    display: inline-block;
    width: 100%;
    background-color: rgba(0, 0, 0, 0);
    color: var(--text);
    border: none;
    font-size: 400%;
    font-family: "Source Serif 4", serif;
}

input:focus, textarea:focus, [contenteditable="true"]:focus {
    outline: none;
    box-shadow: none;
}

input#author {
    position: relative;
    display: inline-block;
    width: 100%;
    background-color: rgba(0, 0, 0, 0);
    color: var(--text);
    border: none;
    margin-left: 2px;
    margin-top: 10px;
    font-size: 85%;
    color: var(--muted);
}

.story {
    position: relative;
    display: inline-block;
    width: 100%;
    min-height: 400px;
}

.story-actions {
    position: absolute;
    left: -48px;
    top: 2px;
    z-index: 5;
}

.story-actions button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border: none;
    border-radius: 50%;
    background-color: transparent;
    color: var(--muted);
    cursor: pointer;
}

.story-actions button:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.editor {
    position: relative;
    display: block;
    width: calc(100% - 3px);
    left: 3px;
    min-height: 400px;
    padding-bottom: 120px;
    background-color: rgba(0, 0, 0, 0);
    color: var(--text);
    border: none;
    font-family: "Source Serif 4", serif;
    font-size: 125%;
    line-height: 1.68;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    caret-color: var(--accent);
}

.editor:empty::before {
    content: attr(data-placeholder);
    color: var(--muted);
    pointer-events: none;
}

.editor b,
.editor strong {
    font-weight: 500;
}

.editor i,
.editor em {
    font-style: italic;
}

.editor a {
    color: var(--accent);
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 0.18em;
}

.editor p,
.editor div {
    margin: 0 0 0.9em;
}

.editor blockquote {
    margin: 24px 0;
    padding: 0 0 0 24px;
    border-left: 3px solid var(--accent);
    color: var(--muted);
    font-size: 112%;
    font-style: italic;
}

.editor figure {
    position: relative;
    margin: 32px auto;
    width: 100%;
    max-width: 100%;
    outline: 2px solid transparent;
    outline-offset: 8px;
    transition: outline-color 0.16s ease;
}

.editor figure + p,
.editor figure + div {
    margin-top: 0;
}

.editor figure.selected {
    outline-color: var(--accent);
}

.editor img {
    display: block;
    width: 100%;
    max-height: 70vh;
    object-fit: contain;
    border-radius: 4px;
}

.editor figcaption {
    min-height: 24px;
    margin-top: 10px;
    color: var(--muted);
    font-family: "Manrope", sans-serif;
    font-size: 72%;
    line-height: 1.45;
    text-align: center;
}

.editor figcaption:empty::before {
    content: attr(data-placeholder);
    color: var(--faint);
    pointer-events: none;
}

.image-size-panel {
    position: absolute;
    top: 10px;
    right: 10px;
    display: none;
    gap: 4px;
    margin: 0;
    padding: 4px;
    border: 1px solid var(--line);
    border-radius: 7px;
    background-color: var(--surface);
    box-shadow: 0 10px 24px var(--color-shadow);
}

.editor figure.selected .image-size-panel {
    display: flex;
}

.image-size-panel button {
    width: 36px;
    height: 28px;
    border: none;
    border-radius: 5px;
    background-color: transparent;
    color: var(--text);
    font-family: "Manrope", sans-serif;
    font-size: 76%;
    cursor: pointer;
}

.image-size-panel button:hover {
    background-color: var(--surface-hover);
    color: var(--accent);
}

.image-resize-handle {
    position: absolute;
    right: -9px;
    bottom: 38px;
    display: none;
    width: 18px;
    height: 18px;
    border: 2px solid var(--bg);
    border-radius: 50%;
    background-color: var(--accent);
    box-shadow: 0 6px 18px var(--color-shadow);
    cursor: ew-resize;
}

.editor figure.selected .image-resize-handle {
    display: block;
}

.editor img::selection,
.editor figure::selection {
    background-color: transparent;
}

.editor-toolbar {
    position: absolute;
    z-index: 10;
    display: none;
    align-items: center;
    gap: 4px;
    padding: 5px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background-color: var(--surface);
    box-shadow: 0 12px 36px var(--color-shadow);
    transform: translate(-50%, calc(-100% - 10px));
}

.editor-toolbar.visible {
    display: flex;
}

.editor-toolbar::after {
    content: "";
    position: absolute;
    left: 50%;
    bottom: -6px;
    width: 10px;
    height: 10px;
    background-color: var(--surface);
    border-right: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
    transform: translateX(-50%) rotate(45deg);
}

.editor-toolbar > button {
    position: relative;
    z-index: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 30px;
    border: none;
    border-radius: 6px;
    background-color: transparent;
    color: var(--text);
    font-family: "Manrope", sans-serif;
    font-size: 92%;
    cursor: pointer;
}

.editor-toolbar > button[data-command="bold"] {
    font-weight: 600;
}

.editor-toolbar > button[data-command="italic"] {
    font-style: italic;
    font-family: "Source Serif 4", serif;
}

.editor-toolbar > button#quote-button {
    font-family: "Source Serif 4", serif;
    font-size: 105%;
    font-style: italic;
}

.editor-toolbar > button:hover,
.editor-toolbar > button.active {
    background-color: var(--surface-hover);
    color: var(--accent);
}

.editor.drag-over {
    background-color: color-mix(in srgb, var(--accent) 10%, transparent);
}

.image-dialog[hidden] {
    display: none;
}

.image-dialog {
    position: fixed;
    inset: 0;
    z-index: 30;
    display: grid;
    place-items: center;
    padding: 24px;
    background-color: var(--color-overlay);
}

.image-dialog__panel {
    width: min(430px, 100%);
    border: 1px solid var(--line);
    border-radius: 8px;
    background-color: var(--surface);
    box-shadow: 0 24px 70px var(--color-shadow);
}

.image-dialog form {
    display: grid;
    gap: 16px;
    padding: 18px;
}

.image-dialog__head,
.image-dialog__actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.image-dialog h2 {
    margin: 0;
    color: var(--text);
    font-size: 110%;
    font-weight: 600;
}

.image-dialog label {
    display: grid;
    gap: 7px;
    color: var(--muted);
    font-size: 82%;
}

.image-dialog input {
    width: 100%;
    height: 38px;
    padding: 0 11px;
    border: 1px solid var(--line);
    border-radius: 7px;
    background-color: var(--bg);
    color: var(--text);
    font: inherit;
    box-sizing: border-box;
}

.image-dialog input:focus {
    border-color: var(--accent);
}

.image-dialog button {
    min-width: 86px;
    height: 34px;
    border: none;
    border-radius: 7px;
    background-color: transparent;
    color: var(--text);
    cursor: pointer;
}

.image-dialog__head button {
    min-width: 34px;
    width: 34px;
    font-size: 135%;
    line-height: 1;
}

.image-dialog__actions button[type="submit"] {
    border-color: var(--accent-strong);
    background-color: var(--accent);
    color: var(--bg);
}

.image-dialog button:hover {
    opacity: 0.86;
}

input::placeholder {
    color: var(--muted);
}

.tools {
    position: relative;
    display: inline-block;
    text-align: right;
    width: 100%;
}

.tools > .copyright {
    position: relative;
    display: inline-block;
    margin-top: 10px;
    font-size: 90%;
    margin-right: 5px;
    color: var(--faint);
}

.tools > .copyright > a {
    color: var(--accent);
    text-decoration: none;
    opacity: .8;
}

@media (max-width: 768px) {
    .upbar > .content {
        width: 90%;
    }

    .main { 
        width: 90%;
    }

    .story-actions {
        position: relative;
        left: 0;
        top: 0;
        margin-bottom: 14px;
    }

    .editor {
        font-size: 115%;
    }
}

.alert {
    transition: 0.4s;
    -webkit-transition: 0.4s;
    position: fixed;
    display: inline-block;
    right: 50px;
    bottom: -200px;
    width: 200px;
    font-size: 90%;
    background-color: var(--leaf-700);
    padding: 15px;
    border-radius: 5px;
}

.alert.show {
    transition: 0.4s;
    -webkit-transition: 0.4s;
    bottom: 50px;
}
