:root {
    --paper: #f7f3e8;
    --paper-strong: #efe6d1;
    --ink: #2f2a27;
    --muted: #8a7d69;
    --line: rgba(122, 103, 79, 0.28);
    --shadow: rgba(72, 55, 33, 0.12);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background: linear-gradient(180deg, #f4efe7 0%, #efeadf 100%);
    color: var(--ink);
    font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
}

#notepad-container {
    width: 100%;
    min-height: 100vh;
    padding: 0;
    background: transparent;
    position: relative;
    display: block;
}

#status {
    display: inline-block;
    margin: 0;
    padding: 0.8rem 0 0.7rem;
    font-size: 0.74rem;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--muted);
    background: transparent;
    position: relative;
    z-index: 1;
}

#top-controls {
    position: absolute;
    top: 0.35rem;
    right: 1.5rem;
    z-index: 2;
    display: flex;
    align-items: center;
    overflow: hidden;
    border: 1px solid rgba(128, 112, 88, 0.18);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.18);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.28);
}

#status {
    padding-left: 1.5rem;
    border-bottom: 1px solid rgba(128, 112, 88, 0.18);
}

.achievements-link {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.3rem 0.75rem;
    border-right: 1px solid rgba(128, 112, 88, 0.18);
    color: var(--ink);
    font-size: 0.74rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-decoration: none;
    text-transform: uppercase;
    transition: background 0.2s ease, transform 0.2s ease;
}

.achievements-link:hover {
    background: rgba(255, 255, 255, 0.42);
    transform: translateY(-1px);
}

.achievements-link:active {
    transform: translateY(0);
}

.achievements-link:focus-visible {
    outline: 2px solid var(--muted);
    outline-offset: 3px;
}

#distraction-counter {
    display: inline-block;
    padding: 0.3rem 0.7rem;
    border-right: 1px solid rgba(128, 112, 88, 0.18);
    background: rgba(255, 255, 255, 0.18);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.28);
    color: var(--muted);
    font-size: 0.74rem;
    font-weight: 700;
    letter-spacing: 0.14em;
    opacity: 0.95;
    text-transform: uppercase;
    vertical-align: middle;
    cursor: pointer;
    transition: background 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
}

#word-counter {
    display: inline-block;
    padding: 0.3rem 0.7rem;
    background: rgba(255, 255, 255, 0.18);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.28);
    color: var(--muted);
    font-size: 0.74rem;
    font-weight: 700;
    letter-spacing: 0.14em;
    opacity: 0.95;
    text-transform: uppercase;
    vertical-align: middle;
    cursor: pointer;
    transition: background 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
}

#distraction-counter:hover,
#word-counter:hover {
    background: rgba(255, 255, 255, 0.42);
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.55);
    opacity: 1;
}

#distraction-counter:active,
#word-counter:active {
    background: rgba(255, 255, 255, 0.38);
    opacity: 1;
}

#notepad {
    position: relative;
    z-index: 1;
    display: block;
    width: 100%;
    min-height: calc(100vh - 48px);
    margin: 0;
    padding: 0.1rem 1.5rem 2rem;
    border: none;
    outline: none;
    resize: none;
    background: var(--paper);
    color: var(--ink);
    font-size: 1.08rem;
    line-height: 1.6;
    font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
    letter-spacing: 0.01em;
    box-shadow: inset 0 0 0 1px rgba(128, 112, 88, 0.18);
    background-image: linear-gradient(
        to bottom,
        transparent 0,
        transparent calc(1.6em - 3px),
        var(--line) calc(1.6em - 2px),
        transparent calc(1.6em - 1px),
        transparent 100%
    );
    background-size: 100% 1.6em;
    /* vertical-align: top; */
    box-sizing: border-box;
    border-radius: 0;
    appearance: none;
    -webkit-appearance: none;
    transform: translateY(-5px);
}

#notepad::placeholder {
    color: rgba(90, 78, 63, 0.5);
    font-style: italic;
}

dialog {
    border: 1px solid rgba(128, 112, 88, 0.28);
    border-radius: 8px;
    padding: 2rem;
    background: var(--paper);
    color: var(--ink);
    box-shadow: 0 10px 32px var(--shadow), inset 0 1px 0 rgba(255, 255, 255, 0.5);
    font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
}

dialog h2 {
    margin-top: 0;
    margin-bottom: 1.5rem;
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--ink);
}

dialog button {
    padding: 0.6rem 1.2rem;
    margin-right: 0.8rem;
    margin-top: 1rem;
    border: 1px solid rgba(128, 112, 88, 0.28);
    border-radius: 4px;
    background: var(--paper-strong);
    color: var(--ink);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s ease, box-shadow 0.2s ease;
}

dialog button:hover {
    background: rgba(239, 230, 209, 0.8);
    box-shadow: 0 4px 8px var(--shadow);
}

dialog button:active {
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
}

#notepad:focus {
    box-shadow: none;
}

.unlocked-toast {
    position: fixed;
    left: 50%;
    bottom: 30px;
    z-index: 10;
    width: min(90%, 360px);
    padding: 1rem 1.25rem;
    background: var(--paper-strong);
    color: var(--ink);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 8px 24px var(--shadow);
    opacity: 0;
    transform: translate(-50%, 20px);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.unlocked-toast.show {
    opacity: 1;
    transform: translate(-50%, 0);
}

.toast-title,
.toast-desc {
    display: block;
}

.toast-desc {
    margin-top: 0.35rem;
}
