:root {
    --pink: #D60270;
    --purple: #9B4F96;
    --blue: #0038A8;
    --bg-dark: #121212;
    --bg-card: #1e1e1e;
    --text-main: #f0f0f0;
    --accent: linear-gradient(90deg, var(--pink), var(--purple), var(--blue));

    /* extra helpers -------------------------------------------------- */
    --red-600: #dc2626;
    --surface-hov: #262626;

    --editor-font: "Fira Code", Menlo, monospace;
    --editor-size: 18px;
    --editor-pad: .5rem;
}

/* Typography & base reset -------------------------------------- */
@font-face {
    font-family: "ngnl";
    src: url("static/font/ngnl_font.ttf");
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html,
body {
    height: 100%;
}

body {
    margin: 0;
    font-family: 'Atkinson Hyperlegible', system-ui, sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-main);
    overflow-x: hidden;
}

/* Authentication UI ----------------------------------------------- */
.auth-notice {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background-color: var(--bg-dark);
}

.auth-notice-card {
    background-color: var(--bg-card);
    padding: 2rem;
    border-radius: 8px;
    text-align: center;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
    max-width: 400px;
    width: 90%;
}

.auth-notice-card h2 {
    margin-top: 0;
    margin-bottom: 1rem;
    color: var(--text-main);
}

.auth-notice-card p {
    margin-bottom: 1.5rem;
    color: #b0b0b0;
}

.auth-header {
    display: flex;
    justify-content: flex-end;
    padding: 0.5rem 1rem;
    border-bottom: 1px solid var(--bg-card);
    margin-bottom: 1rem;
}

.authenticated-content {
    min-height: 100vh;
}

header {
    display: flex;
    align-items: center;
    border-bottom: 1px solid var(--bg-card);
    padding: 1rem;
}

header img {
    width: 64px;
    height: 64px;
    padding-right: 10px;
}

header h1,
header p {
    margin: 0;
}

header h1 {
    font-size: 2rem;
    font-weight: 600;
}

ul,
li {
    margin: 0;
    padding: 0;
    list-style: none;
}

li {
    height: 30px;
}

a {
    text-decoration: none;
}

a:hover {
    text-decoration: none;
}

a+.btn,
button {
    border: none;
    padding: 0;
    font: inherit;
    background: none;
    cursor: pointer;
    transition: background-color .15s ease, transform .15s ease;
}

img,
svg {
    display: block;
    max-width: 100%;
    height: auto;
}

.icon {
    height: 20px;
}

.login-container {
    align-items: center;
    height: 100vh;
}

.login-card {
    display: flex;
    flex-direction: column;
    background-color: var(--bg-card);
    border-radius: 10px;
    width: 260px;
    padding: 20px;
    margin-bottom: 0 !important;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
    text-align: center;
    transition: transform 0.3s;
}

.login-logo {
    width: 128px;
    height: 128px;
}

.input {
    margin-bottom: 1.5em;
    background-color: var(--bg-card);
    color: var(--text-main);
    border: 1px solid var(--surface-hov);
    border-radius: 4px;
    padding: .5rem;
    font-size: 1rem;
    transition: border-color .15s ease;
}

.input:focus-visible {
    outline: 2px solid var(--purple);
}

.enter_password {
    color: white !important;
}

/* Selection ------------------------------------------------------- */
*::selection,
*::-moz-selection {
    background-color: #000;
    color: var(--text-main);
}

*:focus {
    caret-color: var(--text-main) !important;
}

textarea:focus-visible {
    outline: 2px solid var(--purple);
    border-radius: 3px;
}

/* Spacing utilities ----------------------------------------------- */
.space-y-1>:not([hidden])~:not([hidden]) {
    margin-top: .25rem;
}

.space-y-2>:not([hidden])~:not([hidden]) {
    margin-top: .5rem;
}

.space-y-4>:not([hidden])~:not([hidden]) {
    margin-top: 1rem;
}

.space-y-6>:not([hidden])~:not([hidden]) {
    margin-top: 1.5rem;
}

.mb-1 {
    margin-bottom: .25rem;
}

.mb-2 {
    margin-bottom: .5rem;
}

.mb-4 {
    margin-bottom: 1rem;
}

.mt-1 {
    margin-top: .25rem;
}

.mt-4 {
    margin-top: 1rem;
}

.pt-4 {
    padding-top: 1rem;
}

.p-4 {
    padding: 1rem;
}

.gap-2 {
    gap: .5rem;
}

.gap-3 {
    gap: .75rem;
}

.px-1 {
    padding-inline: .25rem;
}

.p-2 {
    padding: .5rem;
}

.p-3 {
    padding: .75rem;
}

/* Flex & Grid helpers ------------------------------------------ */
.flex {
    display: flex;
}

.flex-col {
    flex-direction: column;
}

.justify-center {
    justify-content: center;
}

.justify-between {
    justify-content: space-between;
}

.items-center {
    align-items: center;
}

.items-start {
    align-items: flex-start;
}

.flex-grow {
    flex: 1 1 auto;
}

.grid {
    display: grid;
}

.grid-cols-4 {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.col-span-1 {
    grid-column: span 1/span 1;
}

.col-span-3 {
    grid-column: span 3/span 3;
}

/* Size helpers -------------------------------------------------- */
.h-full {
    height: 100%;
}

.h-90 {
    height: 90%;
}

.h-screen {
    height: calc(100vh - 64px - 16px - 16px - 1px);
}

.w-full {
    width: 100%;
}

/* Colour utilities --------------------------------------------- */
.bg-card {
    background-color: var(--bg-card);
}

.text-red-600 {
    color: var(--red-600);
}

/* Border & radius ---------------------------------------------- */
.border {
    border: 1px solid var(--surface-hov);
}

.border-r {
    border-right: 1px solid var(--surface-hov);
}

.border-t {
    border-top: 1px solid var(--surface-hov);
}

.border-b {
    border-bottom: 1px solid var(--surface-hov);
}

.pb-2 {
    padding-bottom: 0.5rem;
}

.rounded {
    border-radius: .25rem;
}

/* Interaction --------------------------------------------------- */
.cursor-pointer {
    cursor: pointer;
}

.hover\:bg-surface:hover {
    background-color: var(--surface-hov);
}

/* shared subtle hover */
.overflow-y-auto {
    overflow-y: auto;
}

/* Specific component styling ====================================== */

/* File-browser header */
.file-browser-container-header {
    height: 47px;
}

/* File‑browser list items */
li {
    transition: background-color .15s ease;
}

li.hover\:bg-card:hover {
    background-color: var(--surface-hov);
}

/* Toolbar buttons -------------------------------------------------- */
.btn {
    padding: .5rem 1rem;
    border-radius: .25rem;
    color: #fff;
    font-weight: 600;
}

/* Create / Save */
.btn-primary {
    border: 1px solid var(--pink);
}

.btn-primary:hover {
    background-color: var(--pink);
}

/* Move */
.btn-secondary {
    border: 1px solid var(--purple);
}

.btn-secondary:hover {
    background-color: var(--purple);
}

/* Delete */
.btn-danger {
    border: 1px solid var(--red-600);
}

.btn-danger:hover {
    background-color: var(--red-600);
}

.btn:disabled {
    opacity: .35;
    cursor: not-allowed;
}

/* Text utilities ---------------------------------------------- */
.text-sm {
    font-size: .875rem;
    line-height: 1.25rem;
}

.text-xl {
    font-size: 1.25rem;
    line-height: 1.75rem;
}

.font-bold {
    font-weight: 700;
}

.font-medium {
    font-weight: 500;
}

.block {
    display: block;
}

/* Width utilities ---------------------------------------------- */
.w-32 {
    width: 8rem;
}

/* Textarea (code editor) ------------------------------------------ */
textarea {
    resize: vertical;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace;
    background-color: var(--bg-card);
    color: var(--text-main);
    border: 1px solid var(--surface-hov);
    border-radius: .25rem;
    padding: .5rem;
}

#filename {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace;
    padding-block: 0.5rem;
}

/* container keeps the layers stacked */
.editor-container {
    position: relative;
    width: 100%;
    height: 100%;
    font-family: var(--editor-font);
    font-size: var(--editor-size);
    line-height: 1.45;
    /* keep lines tall enough for most fonts */
    margin: 0;
    /* Ensure consistent font rendering */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

/* ────────── legacy highlight layer (no longer used) ────────── */
.editor-highlight {
    display: none; /* This layer is no longer needed with contenteditable */
}

/* ────────── contenteditable editor ────────── */
.editor-content {
    position: absolute;
    inset: 0;
    padding: var(--editor-pad);
    border: 1px solid #ccc;
    border-radius: 4px;
    background: var(--bg-card);
    color: var(--text-main);
    font: inherit;
    /* inherits family, size, line-height */
    overflow: auto;
    margin: 0;
    /* remove UA-default margin */
    /* Perfect layout sync */
    box-sizing: border-box;
    white-space: pre-wrap;
    word-wrap: break-word;
    tab-size: 4;
    /* Prevent font rendering differences */
    font-variant-ligatures: none;
    font-feature-settings: normal;
    letter-spacing: inherit;
    word-spacing: inherit;
    /* Disable browser spell checking and autocorrect */
    -webkit-user-modify: read-write-plaintext-only;
    user-select: text;
    /* Better text editing behavior */
    word-break: keep-all;
    word-wrap: normal;
    /* Disable browser-specific text manipulation */
    -webkit-text-size-adjust: none;
    -moz-text-size-adjust: none;
    text-size-adjust: none;
}

.editor-content:focus {
    outline: none;
    border-color: var(--blue);
    box-shadow: 0 0 0 2px rgba(0, 56, 168, 0.2);
}


/* ────────── Enhanced syntax highlighting ────────── */

/* Keywords (JavaScript, CSS, YAML, TOML, Dockerfile) */
.keyword {
    color: #ff6b6b;  /* Bright red for keywords */
    font-weight: 600;
}

/* Legacy support */
.kw {
    color: #ff6b6b;
    font-weight: 600;
}

/* HTML tags */
.tag {
    color: #51cf66;  /* Green for HTML tags */
    font-weight: 500;
}

/* String literals */
.string {
    color: #ffd93d;  /* Yellow for strings */
}

/* Numbers */
.number {
    color: #74c0fc;  /* Light blue for numbers */
    font-weight: 500;
}

/* Comments */
.comment {
    color: #868e96;  /* Gray for comments */
    font-style: italic;
}

/* Attributes, decorators, CSS selectors */
.attr {
    color: #ff8cc8;  /* Pink for attributes */
}

/* CSS selectors (.class, #id) */
.selector {
    color: #da77f2;  /* Purple for CSS selectors */
    font-weight: 500;
}

/* Colors (hex, rgb, hsl) */
.color {
    color: #20c997;  /* Teal for color values */
    font-weight: 600;
    background: rgba(32, 201, 151, 0.1);
    padding: 1px 3px;
    border-radius: 3px;
}

/* URLs */
.url {
    color: #fd7e14;  /* Orange for URLs */
    text-decoration: underline;
}

/* CSS pseudo-classes and pseudo-elements */
.pseudo {
    color: #e599f7;  /* Light purple for :hover, ::before, etc. */
    font-style: italic;
}

/* CSS at-rules (@media, @keyframes, etc.) */
.atrule {
    color: #ff8787;  /* Light red for @rules */
    font-weight: 700;
}

/* Constants (UPPERCASE_VARS) */
.constant {
    color: #91a7ff;  /* Light blue for constants */
    font-weight: 600;
    text-transform: uppercase;
}

/* Enhanced number highlighting */
.number {
    color: #74c0fc;  /* Light blue for numbers */
    font-weight: 500;
    background: rgba(116, 192, 252, 0.1);
    padding: 1px 2px;
    border-radius: 2px;
}

/* Selection highlighting */
.editor-highlight::selection {
    background: rgba(116, 192, 252, 0.3);  /* Light blue selection */
}

/* Focus and hover states for better UX */
.editor-container:hover .editor-input {
    border-color: var(--purple);
    transition: border-color 0.2s ease;
}

/* Enhanced visual feedback */
.editor-container:focus-within .editor-input {
    border-color: var(--blue);
    box-shadow: 0 0 0 2px rgba(0, 56, 168, 0.2);
    transition: all 0.2s ease;
}

/* Improved cursor visibility */
.editor-input:focus {
    caret-color: var(--text-main);
}


/* Scrollbar (webkit) ---------------------------------------------- */
aside.overflow-y-auto::-webkit-scrollbar {
    width: 6px;
}

aside.overflow-y-auto::-webkit-scrollbar-thumb {
    background-color: rgba(255, 255, 255, .15);
    border-radius: 3px;
}

/* Settings page specific styles ----------------------------------- */
.settings-page {
    max-width: 800px;
    margin: 0 auto;
}

.settings-page input[type="checkbox"] {
    width: 1rem;
    height: 1rem;
    accent-color: var(--purple);
}

.settings-page input[type="number"] {
    -moz-appearance: textfield;
    appearance: textfield;
}

.settings-page input[type="number"]::-webkit-outer-spin-button,
.settings-page input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}