:root {
    --bg:        #0e1116;
    --panel:     #161b22;
    --panel-2:   #1c232c;
    --border:    #2a313c;
    --text:      #e6edf3;
    --muted:     #8b949e;
    --accent:    #58a6ff;
    --accent-2:  #1f6feb;
    --danger:    #f85149;
    --ok:        #3fb950;
    --mono:      ui-monospace, SFMono-Regular, "JetBrains Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 15px;
    line-height: 1.5;
}

.wrap {
    max-width: 1000px;
    margin: 0 auto;
    padding: 32px 20px 80px;
}

header h1 {
    margin: 0;
    font-size: 24px;
    letter-spacing: -0.01em;
}

header .sub {
    margin: 4px 0 24px;
    color: var(--muted);
    font-size: 13px;
}

code, .mono {
    font-family: var(--mono);
}
code {
    background: var(--panel-2);
    border: 1px solid var(--border);
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 13px;
}
.small { font-size: 12px; }

a {
    color: var(--accent);
    text-decoration: none;
}
a:hover { text-decoration: underline; }

/* Tabs */
.tabs {
    display: flex;
    gap: 2px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 24px;
}
.tabs a {
    padding: 10px 16px;
    color: var(--muted);
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    font-weight: 500;
}
.tabs a.active {
    color: var(--text);
    border-bottom-color: var(--accent);
}
.tabs a:hover { color: var(--text); text-decoration: none; }

/* Cards */
.card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 24px;
    margin-bottom: 20px;
}
.card h2 {
    margin: 0 0 8px;
    font-size: 18px;
}
.card h3 {
    margin: 20px 0 8px;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted);
}
.muted { color: var(--muted); font-size: 13px; }

/* Forms */
form {
    display: grid;
    gap: 14px;
    margin-top: 16px;
}
label {
    display: flex;
    flex-direction: column;
    font-size: 13px;
    color: var(--muted);
    gap: 6px;
}
label.check {
    flex-direction: row;
    align-items: center;
    gap: 8px;
}
input[type="text"],
input[type="number"],
input[type="file"],
select {
    background: var(--panel-2);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 9px 12px;
    font: inherit;
    font-size: 14px;
}
input[type="text"]:focus,
input[type="number"]:focus,
select:focus {
    outline: none;
    border-color: var(--accent);
}
input[type="file"] { padding: 7px 10px; }

button {
    justify-self: start;
    background: var(--accent-2);
    color: white;
    border: none;
    border-radius: 6px;
    padding: 9px 18px;
    font: inherit;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s;
}
button:hover { background: var(--accent); }
button.primary { background: var(--ok); }
button.primary:hover { background: #46c45a; }
button.danger {
    background: transparent;
    color: var(--danger);
    border: 1px solid var(--danger);
}
button.danger:hover { background: rgba(248, 81, 73, 0.1); }
button.link-btn {
    background: transparent;
    border: none;
    color: var(--muted);
    padding: 4px 6px;
    font-size: 16px;
}
button.link-btn:hover { background: var(--panel-2); color: var(--text); }
button.link-btn.danger { color: var(--danger); border: none; }
button.link-btn.danger:hover { background: rgba(248, 81, 73, 0.15); }

a.btn-dl {
    background: var(--ok);
    color: white;
    border-radius: 6px;
    padding: 9px 18px;
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    transition: background 0.15s;
    display: inline-block;
}
a.btn-dl:hover {
    background: #46c45a;
    text-decoration: none;
}

/* Alerts */
.alert {
    border-radius: 6px;
    padding: 12px 16px;
    margin-bottom: 20px;
    font-size: 14px;
}
.alert.error {
    background: rgba(248, 81, 73, 0.1);
    border: 1px solid rgba(248, 81, 73, 0.4);
    color: #ffa198;
}
.alert.ok {
    background: rgba(63, 185, 80, 0.1);
    border: 1px solid rgba(63, 185, 80, 0.4);
    color: #7ee787;
}
.alert.info {
    background: rgba(88, 166, 255, 0.1);
    border: 1px solid rgba(88, 166, 255, 0.4);
    color: #79c0ff;
}

.wrap.narrow {
    max-width: 480px;
}

/* Result */
.result-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
}

table.kv {
    width: 100%;
    border-collapse: collapse;
    margin-top: 12px;
    font-size: 14px;
}
table.kv th,
table.kv td {
    text-align: left;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
}
table.kv th {
    color: var(--muted);
    font-weight: normal;
    width: 180px;
    font-family: var(--mono);
    font-size: 13px;
}
table.kv tr:last-child th,
table.kv tr:last-child td {
    border-bottom: none;
}

/* History */
table.history {
    width: 100%;
    border-collapse: collapse;
    margin-top: 16px;
    font-size: 14px;
}
table.history th,
table.history td {
    text-align: left;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
}
table.history th {
    color: var(--muted);
    font-weight: 500;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom: 1px solid var(--border);
}
table.history tbody tr:hover { background: rgba(88, 166, 255, 0.04); }
table.history tbody tr:last-child td { border-bottom: none; }

.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 500;
}
.badge-dec { background: rgba(63, 185, 80, 0.15); color: var(--ok); }
.badge-enc { background: rgba(88, 166, 255, 0.15); color: var(--accent); }

.row-actions {
    white-space: nowrap;
    text-align: right;
}

/* Invite-link display: readonly input + copy button side-by-side. */
.invite-link {
    display: flex;
    gap: 6px;
    align-items: stretch;
    min-width: 280px;
}
.invite-link input[type="text"] {
    flex: 1 1 auto;
    min-width: 0;       /* lets the input shrink to fit the cell */
    padding: 6px 10px;
    font-size: 12px;
}
.invite-link input[type="text"]:focus,
.invite-link input[type="text"]:hover {
    border-color: var(--accent);
}
.invite-link .link-btn {
    flex: 0 0 auto;
    padding: 4px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
}
.invite-link .link-btn:hover {
    border-color: var(--accent);
}

.invite-callout {
    border-color: rgba(63, 185, 80, 0.4);
}

.user-actions {
    white-space: nowrap;
}
.user-actions form { display: inline-block; }
.user-actions .link-btn {
    padding: 4px 7px;
    font-size: 15px;
}
.tier-form { margin: 0; }
.tier-form select { padding: 5px 8px; font-size: 13px; }
.row-actions a, .row-actions form { display: inline-block; }
.row-actions a {
    padding: 4px 8px;
    border-radius: 4px;
    text-decoration: none;
    font-size: 16px;
}
.row-actions a:hover { background: var(--panel-2); text-decoration: none; }

img.icon {
    margin-top: 8px;
    background: var(--panel-2);
    border: 1px solid var(--border);
    padding: 8px;
    border-radius: 6px;
    max-width: 128px;
    image-rendering: pixelated;
}

details { margin-top: 16px; }
details summary {
    cursor: pointer;
    color: var(--muted);
    font-size: 13px;
    user-select: none;
}
details summary:hover { color: var(--text); }

pre {
    background: var(--panel-2);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 14px;
    overflow: auto;
    font-family: var(--mono);
    font-size: 12.5px;
    margin: 8px 0 0;
    line-height: 1.45;
}

footer {
    margin-top: 40px;
    text-align: center;
}