:root {
    --bg: #f4efe6;
    --paper: #fffdf8;
    --panel: rgba(255, 253, 248, 0.92);
    --ink: #17120d;
    --muted: #6c6256;
    --line: #d9cebf;
    --accent: #9d4b22;
    --accent-dark: #7a3818;
    --danger: #9c2f2f;
    --shadow: 0 20px 45px rgba(55, 33, 16, 0.12);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    color: var(--ink);
    background:
        radial-gradient(circle at top left, rgba(157, 75, 34, 0.16), transparent 28%),
        radial-gradient(circle at top right, rgba(59, 91, 71, 0.12), transparent 25%),
        linear-gradient(180deg, #f9f5ee 0%, var(--bg) 100%);
    font-family: Georgia, "Times New Roman", serif;
    min-height: 100vh;
}

a {
    color: inherit;
}

.page-shell {
    padding: 28px 20px 48px;
}

.site-header,
.container {
    max-width: 960px;
    margin: 0 auto;
}

.site-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin-bottom: 28px;
}

.brand {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-decoration: none;
}

.site-nav {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.nav-user {
    color: var(--muted);
    font-size: 0.95rem;
}

.container {
    display: grid;
    gap: 20px;
}

.panel {
    background: var(--panel);
    border: 1px solid rgba(217, 206, 191, 0.9);
    border-radius: 20px;
    box-shadow: var(--shadow);
    padding: 28px;
    backdrop-filter: blur(6px);
}

.hero-panel {
    padding: 40px 32px;
}

.auth-panel {
    max-width: 560px;
}

.eyebrow {
    margin: 0 0 10px;
    color: var(--accent);
    font-size: 0.85rem;
    font-weight: 700;
    letter-spacing: 0.16em;
    text-transform: uppercase;
}

h1 {
    margin: 0 0 14px;
    font-size: clamp(2rem, 5vw, 3.25rem);
    line-height: 1;
}

.lede {
    margin: 0 0 24px;
    color: var(--muted);
    font-size: 1.05rem;
    line-height: 1.6;
}

.stack-form {
    display: grid;
    gap: 12px;
}

.action-grid {
    display: grid;
    gap: 16px;
    margin-bottom: 16px;
}

.inline-actions,
.inline-form {
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.search-divider {
    margin: 16px 0;
    color: var(--muted);
    font-size: 0.9rem;
    font-style: italic;
}

label {
    font-weight: 700;
}

input[type="text"],
input[type="password"],
input[type="email"] {
    width: 100%;
    padding: 14px 16px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--paper);
    color: var(--ink);
    font: inherit;
}

input:focus {
    border-color: var(--accent);
    outline: 2px solid rgba(157, 75, 34, 0.14);
    outline-offset: 2px;
}

.button {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    min-height: 46px;
    padding: 0 16px;
    border: 0;
    border-radius: 999px;
    background: var(--accent);
    color: #fff7f1;
    cursor: pointer;
    font: inherit;
    font-weight: 700;
    text-decoration: none;
    transition: background-color 120ms ease, transform 120ms ease;
}

.button:hover {
    background: var(--accent-dark);
    text-decoration: none;
    transform: translateY(-1px);
}

.button-secondary {
    background: #e8ddd0;
    color: var(--ink);
}

.button-secondary:hover {
    background: #dcccb9;
}

.button-compact {
    min-height: 36px;
    padding-inline: 12px;
    font-size: 0.9rem;
}

.hint,
.meta,
.guesses,
.auth-link,
.back-link,
.type,
.panel-label {
    color: var(--muted);
}

.name {
    font-size: clamp(2rem, 4vw, 2.6rem);
    font-weight: 700;
    margin-top: 8px;
}

.type {
    margin: 8px 0 20px;
    font-style: italic;
}

.box {
    padding: 18px;
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 14px;
}

.box pre {
    margin: 0;
    white-space: pre-wrap;
    font-family: "Courier New", Courier, monospace;
}

.panel-label {
    margin-bottom: 12px;
    font-size: 0.82rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.panel-header .panel-label {
    margin-bottom: 0;
}

.panel-actions {
    display: inline-flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.backend-badge {
    padding: 4px 10px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--paper);
    color: var(--muted);
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.backend-error {
    margin-bottom: 12px;
    color: var(--danger);
    font-size: 0.88rem;
    line-height: 1.4;
}

.transcript-box {
    background: #f8f3eb;
}

.meta,
.guesses,
.error,
.field-error,
.back-link,
.hint,
.auth-link {
    margin-top: 14px;
}

.error,
.field-error {
    color: var(--danger);
}

.image-panel {
    overflow: hidden;
}

.responsive-image {
    display: block;
    width: 100%;
    height: auto;
    border-radius: 14px;
}

.debug-image {
    border: 2px solid var(--danger);
}

.editable-mask-stage {
    position: relative;
    width: 100%;
    touch-action: none;
}

.editable-mask-layer {
    position: absolute;
    inset: 0;
}

.editable-mask-box {
    position: absolute;
    min-width: 8px;
    min-height: 8px;
    background: rgba(0, 0, 0, 0.84);
    border: 1px solid rgba(255, 255, 255, 0.55);
}

.editable-mask-box.is-active {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.editable-mask-handle {
    position: absolute;
    top: 50%;
    width: 12px;
    height: 12px;
    border: 1px solid #ffffff;
    background: var(--accent);
    cursor: ew-resize;
    transform: translateY(-50%);
}

.editable-mask-handle-left {
    left: -6px;
}

.editable-mask-handle-right {
    right: -6px;
}

.back-link {
    display: inline-block;
    text-decoration: none;
}

.back-link:hover {
    text-decoration: underline;
}

@media (min-width: 760px) {
    .action-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 640px) {
    .page-shell {
        padding-inline: 14px;
    }

    .site-header {
        align-items: flex-start;
        flex-direction: column;
    }

    .panel,
    .hero-panel {
        padding: 22px 18px;
    }
}
