:root {
    --bg: #0a0a0a;
    --fg: #d6ffd6;
    --grid: #153e15;
    --ink: #d6ffd6;
    --link: #7cff7c;
    --muted: #98e698;
    --panel: #0f0f0f;
    --panel-2: #111;
    --border: #1f5d1f;
    --accent: #41ff54;

    /* Used by inputs & tooltips */
    --green-1: #285f28; /* darker frame */
    --green-2: #2c7a2c; /* primary accent border */
    --glow-soft: 0 5px 10px rgba(0, 255, 120, .12), 0 0 1px rgba(0, 0, 0, .45);
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    background: var(--bg);
    color: var(--fg);
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

a {
    color: var(--link);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
    color: #fff;
}

.dash-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 2px solid var(--grid);
}

.dash-header .brand a {
    font-weight: 800;
    letter-spacing: .5px;
}

.dash-nav a {
    margin-left: 12px;
}

.dash-layout {
    max-width: 1200px;
    margin: 18px auto;
    padding: 0 12px;
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 16px;
}

.dash-main {
    min-height: 60vh;
}

.dash-h1 {
    margin: 8px 0 6px;
}

.dash-subtle {
    color: var(--muted);
    margin: 0 0 12px;
}

.card {
    background: var(--panel);
    border: 1px solid var(--border);
    padding: 12px;
}

.card + .card {
    margin-top: 16px;
}

.card-title {
    margin: 0 0 4px;
}

.card-note {
    margin: 0 0 12px;
    color: var(--muted);
}

.retro-form .form-grid {
    display: grid;
    grid-template-columns: 1fr 340px;
    gap: 16px;
}

.retro-form .form-col {
    background: var(--panel-2);
    border: 1px solid var(--border);
    padding: 12px;
}

.retro-form .row {
    margin-bottom: 10px;
}

.retro-form .row.two {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.retro-form label {
    display: block;
    margin-bottom: 6px;
}

.retro-form input[type="text"],
.retro-form input[type="url"],
.retro-form input[type="number"],
.retro-form textarea,
.retro-form select {
    width: 100%;
    padding: 8px;
    background: #000;
    color: var(--ink);
    border: 1px solid var(--border);
    border-radius: 2px;
    outline: none;
}

.retro-form .row-inline {
    display: flex;
    align-items: center;
    gap: 6px;
}

.retro-form .row-inline .x {
    opacity: .7;
}

.retro-form .check {
    display: flex;
    gap: 8px;
    align-items: center;
}

.retro-form .help {
    color: var(--muted);
    font-size: 12px;
}

.err {
    color: #ff6;
    font-size: 12px;
    margin-top: 4px;
}

.actions {
    margin-top: 10px;
}

.btn {
    padding: 8px 12px;
    border: 1px solid var(--border);
    background: #0a0a0a;
    color: var(--fg);
    cursor: pointer;
}

.btn:hover {
    border-color: var(--link);
}

.btn-secondary {
    background: #111;
}

.preview-col .preview {
    border: 1px solid var(--border);
}

.preview-head {
    padding: 8px;
    border-bottom: 1px solid var(--border);
    background: #0b0b0b;
}

.preview-body {
    padding: 10px;
}

#logo-preview-frame {
    width: 250px;
    height: 250px;
    border: 1px solid var(--border);
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

#logo-preview-frame img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    background: transparent;
}

.preview-meta {
    font-size: 12px;
    color: var(--muted);
    margin-top: 8px;
    display: grid;
    gap: 2px;
}

.mini-list {
    margin-top: 12px;
    border: 1px solid var(--border);
}

.mini-head {
    padding: 8px;
    border-bottom: 1px solid var(--border);
    background: #0b0b0b;
}

.mini-list ul {
    margin: 0;
    padding: 8px;
    list-style: none;
}

.mini-list li + li {
    margin-top: 6px;
}

.dash-aside {
    position: sticky;
    top: 12px;
    align-self: start;
}

.aside-title {
    margin: 0 0 4px;
}

.aside-note {
    margin: 0 0 10px;
    color: var(--muted);
}

.aside-select {
    border: 1px solid var(--border);
    padding: 8px;
    background: #111;
    margin-bottom: 10px;
}

.aside-select label {
    display: block;
    margin-bottom: 6px;
}

.aside-select select {
    width: 100%;
    padding: 8px;
    background: #000;
    color: var(--ink);
    border: 1px solid var(--border);
}

.endorse-list {
    display: grid;
    gap: 10px;
}

.endorse-card {
    position: relative;
    border: 1px solid var(--border);
    background: #111;
    padding: 8px;
}

.endorse-card .mini {
    display: flex;
    gap: 8px;
    align-items: center;
}

.endorse-card .mini img {
    width: 28px;
    height: 28px;
    object-fit: contain;
    border: 1px solid var(--border);
    background: #000;
}

.endorse-card .mini-name {
    font-weight: 700;
}

.endorse-card .mini-one {
    font-size: 12px;
    color: var(--muted);
}

.endorse-actions {
    margin-top: 8px;
    display: flex;
    gap: 8px;
}

.endorse-actions .endorse-form {
    display: flex;
    gap: 6px;
    width: 100%;
}

.endorse-actions input[type="text"] {
    flex: 1;
    min-width: 0;
    padding: 6px 8px;
    border: 1px solid var(--border);
    background: #000;
    color: var(--ink);
}

.endorse-popover {
    position: absolute;
    right: 100%;
    top: 0;
    width: 260px;
    transform: translateX(-8px);
    background: #080808;
    border: 1px solid var(--border);
    padding: 10px;
    box-shadow: 0 0 16px rgba(0, 255, 80, .12);
    opacity: 0;
    visibility: hidden;
    transition: opacity .12s ease;
    z-index: 4;
}

.endorse-card:hover .endorse-popover {
    opacity: 1;
    visibility: visible;
}

.endorse-popover .pop-row.logo img {
    width: 100%;
    height: 80px;
    object-fit: contain;
    background: #000;
    border: 1px solid var(--border);
}

.endorse-popover .title {
    font-weight: 700;
    margin-bottom: 4px;
}

.endorse-popover .desc {
    font-size: 12px;
    color: var(--muted);
    margin-bottom: 8px;
}

.form-grid {
    display: grid;
    grid-template-columns:1fr;
    gap: 10px
}

.form-grid .two {
    display: grid;
    grid-template-columns:1fr 1fr;
    gap: 10px
}

/* Endorsement list tooltip — place LEFT of the row */
.aside-sticky .list .tile {
    position: relative;
}

.aside-sticky .list .tile[data-tip]:hover::after {
    content: attr(data-tip);
    position: absolute;
    /* sit to the left of the row */
    right: calc(100% + 12px);
    left: auto;
    top: 50%;
    transform: translateY(-50%);
    background: var(--panel);
    color: var(--fg);
    border: 1px solid var(--green-2);
    border-radius: 10px;
    padding: 8px 10px;
    max-width: 320px;
    width: min(320px, 44vw);
    z-index: 20;
    white-space: normal;
    pointer-events: none; /* don’t steal hover */
    box-shadow: 0 0 0 1px rgba(0, 0, 0, .25) inset, 0 8px 24px rgba(0, 0, 0, .4);
}

/* little arrow pointing at the row */
.aside-sticky .list .tile[data-tip]:hover::before {
    content: "";
    position: absolute;
    top: 50%;
    right: calc(100% + 2px);
    transform: translateY(-50%);
    border: 6px solid transparent;
    border-left-color: var(--green-2); /* outline edge */
}

.aside-sticky .list .tile[data-tip]:hover::before {
    /* inner arrow (fill) */
    box-shadow: -6px 0 0 0 var(--panel);
}

/* Mobile fallback: if the sidebar stacks, show tooltip above */
@media (max-width: 900px) {
    .aside-sticky .list .tile[data-tip]:hover::after {
        right: auto;
        left: 0;
        top: -8px;
        transform: translateY(-100%);
        width: calc(100% - 2px);
    }

    .aside-sticky .list .tile[data-tip]:hover::before {
        display: none;
    }
}

/* Dark textarea to match the theme */
.card textarea {
    background: var(--panel);
    color: var(--fg);
    border: 1px solid var(--green-2);
    border-radius: 10px;
    padding: 10px 12px;
    width: 100%;
    resize: vertical;
}

/* Base thumbnail keeps the retro frame */
.thumb {
    border: 1px solid var(--green-2);
    border-radius: 12px;
    background: var(--panel);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

/* Larger, responsive preview: ~40% of the editor column */
.thumb--preview {
    margin-top: 8px;
    width: 40%;
    min-width: 220px;
    max-width: 520px;
    height: auto; /* let the image define height */
    padding: 8px;
}

/* Image scales while keeping aspect ratio */
.thumb--preview img {
    width: 100%;
    height: auto;
    display: block;
    object-fit: contain;
}


/* --- Inputs/textarea unified --- */
.form-grid input[type="text"],
.form-grid input[type="url"],
.form-grid input[type="number"],
.form-grid select,
.form-grid textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #2c7a2c;
    border-radius: 10px;
    background: #0e1a0e; /* dark greenish */
    color: var(--fg);
    font: inherit;
    outline: none;
}

/* Add breathing room for helper text under fields (only inside .form-grid) */
.form-grid .muted {
    margin-top: 6px;
    display: block;
}

.form-grid textarea#id_description {
    min-height: 0 !important; height: auto;
}

.form-grid textarea#id_img_url {
    min-height: 0 !important; height: auto;
}

/* --- Preview tile --- */
.thumb {
    border: 1px solid #1f5d1f;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background: #0a0a0a;
}

.thumb img {
    width: 100%;
    height: auto;
    object-fit: contain;
}

/* Larger, responsive preview under Img URL */
.thumb--preview {
    width: 40%; /* requested 40% of the column */
    max-width: 480px;
    min-width: 260px;
    /* tweak: keep it compact yet stable */
    max-height: 160px;
    margin-top: 8px;
}

/* REMOVE the legacy centered dot placeholder */
.thumb--preview::before {
    content: none !important;
}

/* Tooltip sits beside the row (right side) */
.list .tile[data-tip] {
    position: relative;
}

.list .tile[data-tip]::after {
    content: attr(data-tip);
    position: absolute;
    left: calc(100% + 10px);
    top: 0;
    max-width: 300px;
    padding: 10px 12px;
    border: 1px solid #285f28;
    border-radius: 10px;
    background: #0e1a0e;
    color: var(--fg);
    white-space: normal;
    opacity: 0;
    transform: translateY(-4px);
    pointer-events: none;
    box-shadow: 0 0 16px rgba(0, 255, 80, 0.08);
    transition: opacity .15s ease, transform .15s ease;
    z-index: 5;
}

.list .tile[data-tip]:hover::after {
    opacity: 1;
    transform: translateY(0);
}

/* Make all textareas match the retro style */
.retro-textarea, .form-grid textarea {
    background: var(--bg);
    color: var(--fg);
    border: 1px solid #1f5d1f;
    border-radius: 10px;
    padding: 8px 10px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
    line-height: 1.3;
    resize: vertical;
}

/* Ensure the Img url field ≈ 3 rows regardless of Django's default rows */
#id_img_url {
    min-height: 0;
    height: 4.8em; /* ~3 lines with 1.6 line-height */
    line-height: 1.6;
}

/* Compact preview below the field (final override to keep it tidy) */
.thumb--preview {
    width: clamp(200px, 40%, 520px);
    max-height: 160px;
    margin-top: 8px;
    border: 1px solid #1f5d1f;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background: #0a0a0a;
}

.thumb--preview img {
    max-width: 100%;
    max-height: 100%;
    height: auto;
    width: auto;
}

/* Stack Visit button under Endorse in the sidebar actions area
   (targets the inline-style flex container only inside the sidebar tiles) */
.aside-sticky .list .tile > div[style*="display:flex"] {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 6px !important;
}
.aside-sticky .list .tile form .btn { width: 100%; }
.aside-sticky .list .tile a.muted { align-self: flex-start; }

/* Clamp long project names in the paid sidebar list to 2 lines */
.aside-sticky .list .tile .meta {
  display: flex;
  gap: 10px;
  align-items: center;
}

.aside-sticky .list .tile .meta > .thumb {
  flex: 0 0 auto;
}

.aside-sticky .list .tile .meta > div {
  flex: 1 1 auto;
  min-width: 0;              /* critical so text can actually shrink */
}

/* the first div inside the text container is the name */
.aside-sticky .list .tile .meta > div > div:first-child {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;     /* two lines max */
  overflow: hidden;
  text-overflow: ellipsis;
  word-break: break-word;     /* break long URLs/identifiers */
  hyphens: auto;              /* nicer wrapping for words */
  white-space: normal;        /* ensure multiline is allowed */
}

/* Clamp long project names to 2 lines with ellipsis */
.tile-name{
  font-weight: 700;
  line-height: 1.2;
  display: -webkit-box;
  -webkit-line-clamp: 2;      /* show max 2 lines */
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  word-break: break-word;      /* break long words if needed */
  overflow-wrap: anywhere;     /* break long URLs */
}

/* existing desktop-ish layout (you probably already have something like this) */
.dash-grid {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(0, 1.4fr);
    gap: 24px;
}

/* sidebar sticks on desktop */
.aside-sticky {
    position: sticky;
    top: 12px;
}

/* ---------- MOBILE LAYOUT ---------- */
@media (max-width: 900px) {

    .dash-grid {
        display: block;           /* stack main + sidebar */
    }

    /* main card gets full width */
    .dash-grid > div,
    .dash-grid > aside {
        width: 100%;
        margin: 0 0 24px;
    }

    /* sidebar: no sticky, no overlap */
    .aside-sticky {
        position: static;
        top: auto;
        max-width: none;
    }

    /* tighten padding a bit so content fits nicely */
    .card {
        padding: 10px 12px;
    }

    /* forms: single column */
    .form-grid {
        display: block;
    }

    .form-grid > div {
        margin-bottom: 16px;
    }

    /* .two group (width/height) becomes vertical */
    .two {
        display: block;
    }
    .two > div {
        width: 100%;
        margin-bottom: 12px;
    }
}
