/* Variables */

:root {
    --background: var(--cd-grey-10, #16191d);
    --surface: var(--cd-grey-20, #23272d);
    --border: var(--cd-grey-30, #353a42);
    --text: #fff;
    --text-muted: var(--cd-grey-60, #8b929c);
    --primary: var(--cd-orange-60, #df7900);
    --primary-hover: var(--cd-orange-70, #ffa226);
    --error-bg: var(--cd-red-40, #8c2b2b);
    --error-hover: var(--cd-red-50, #a63838);
    --success: var(--cd-sea-green-60, #2fa39a);
    --success-hover: var(--cd-sea-green-70, #45bdb3);
    --success-bg: var(--cd-sea-green-40, #1e6b65);
}

/* Reset */

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

/* Layout */

body {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--background);
    color: var(--text);
    font-family: 'Poppins', sans-serif;
    line-height: 1.5;
}

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

a:hover {
    color: var(--primary-hover);
}

h1 {
    font-size: 1.6rem;
    font-weight: 500;
    margin-bottom: 1rem;
}

h2 {
    font-size: 1.15rem;
    font-weight: 500;
    margin-bottom: 0.75rem;
}

.main {
    flex: 1;
    width: 100%;
    max-width: 960px;
    margin: 0 auto;
    padding: 2rem 1rem;
}

.main-wide {
    max-width: 1440px;
}

.muted {
    color: var(--text-muted);
    font-weight: 300;
}

.pre {
    white-space: pre-wrap;
}

.intro {
    margin-bottom: 1.5rem;
}

.stack {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* Header & footer */

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

.header-brand {
    color: var(--text);
    font-weight: 600;
    font-size: 1.1rem;
}

.header-nav {
    display: flex;
    gap: 1.5rem;
    font-size: 0.9rem;
}

.footer {
    padding: 1rem 2rem;
    font-size: 0.8rem;
    font-weight: 300;
    opacity: 0.5;
    text-align: center;
}

/* Components */

.inline {
    display: inline;
}

.link-button {
    padding: 0;
    border: none;
    background: none;
    color: var(--primary);
    font: inherit;
    cursor: pointer;
}

.link-button:hover {
    color: var(--primary-hover);
}

/* Notices (thank you & error pages) */

.notice {
    max-width: 32rem;
    margin: 3rem auto;
    text-align: center;
}

.notice h1 {
    margin-bottom: 1rem;
}

.notice p {
    margin-bottom: 0.5rem;
}

/* Login page */

.welcome {
    position: relative;
    display: flex;
    justify-content: center;
    padding: 3rem 0;
}

.welcome-glow {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 36rem;
    height: 36rem;
    transform: translate(-50%, -50%);
    background: radial-gradient(circle, rgba(223, 121, 0, 0.22) 0%, transparent 65%);
    pointer-events: none;
}

.welcome-card {
    position: relative;
    display: flex;
    align-items: center;
    gap: 2.5rem;
    width: 100%;
    max-width: 52rem;
    padding: 2.5rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
}

.welcome-avatar {
    flex: none;
    display: block;
    width: auto;
    height: 256px;
}

.welcome-text {
    flex: 1;
}

.welcome-title {
    font-size: 1.8rem;
    font-weight: 400;
    margin-bottom: 0.5rem;
}

.welcome-title strong {
    font-weight: 700;
    color: var(--primary);
}

.welcome-tagline {
    text-wrap: pretty;
    color: var(--text-muted);
    font-weight: 300;
    margin-bottom: 0.75rem;
}

.welcome-tagline:last-of-type {
    margin-bottom: 2rem;
}

.btn-large {
    padding: 0.8rem 2rem;
    font-size: 1.05rem;
    border-radius: 8px;
}

.page-head {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.page-head h1 {
    margin: 0;
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

fieldset.card {
    margin: 0;
}

legend {
    font-weight: 500;
    padding: 0 0.5rem;
}

label {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    font-size: 0.9rem;
}

.required {
    color: var(--error-hover);
}

.input {
    width: 100%;
    padding: 0.55rem 0.75rem;
    background: var(--background);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 6px;
    font: inherit;
}

.input:focus {
    outline: none;
    border-color: var(--primary);
}

.inline-form, .btn-group {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
}

.inline-form .input {
    width: auto;
}

.btn {
    display: inline-block;
    padding: 0.55rem 1.2rem;
    border: 1px solid var(--primary);
    border-radius: 6px;
    background: var(--primary);
    color: #fff;
    font: inherit;
    font-weight: 500;
    cursor: pointer;
}

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

.btn-outline {
    background: transparent;
    color: var(--primary);
}

.btn-success {
    background: var(--success);
    border-color: var(--success);
}

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

.btn-success-outline {
    background: transparent;
    border-color: var(--success);
    color: var(--success);
}

.btn-success-outline:hover {
    background: var(--success);
    border-color: var(--success);
    color: #fff;
}

.btn-danger {
    background: var(--error-bg);
    border-color: var(--error-bg);
}

.btn-danger:hover {
    background: var(--error-hover);
}

.btn-small {
    padding: 0.3rem 0.8rem;
    font-size: 0.85rem;
    align-self: flex-start;
}

.btn-icon {
    padding: 0.4rem 0.6rem;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-muted);
    cursor: pointer;
}

.btn-icon:hover {
    color: var(--text);
}

.badge {
    display: inline-block;
    padding: 0.1rem 0.6rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 500;
    vertical-align: middle;
    background: var(--border);
    border: 3px solid var(--border);
}

.badge-sent {
    background: transparent;
    border-color: var(--success);
    color: var(--success);
}

.badge-completed {
    background: var(--success);
    border-color: var(--success);
}

/* Dashboard (forms & files side by side) */

.dashboard {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    align-items: start;
}

.dashboard-panel {
    margin-bottom: 0;
}

.dashboard-panel h2 {
    font-size: 1rem;
}

@media (max-width: 1100px) {
    .dashboard {
        grid-template-columns: 1fr;
    }
}

.form-group {
    margin-bottom: 2rem;
}

.form-group:last-child {
    margin-bottom: 0;
}

.table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}

.table th, .table td {
    text-align: left;
    padding: 0.6rem 0.75rem;
    border-bottom: 1px solid var(--border);
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.table th {
    font-weight: 500;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.meta {
    display: grid;
    grid-template-columns: minmax(8rem, max-content) 1fr;
    gap: 0.5rem 1.5rem;
}

.meta dt {
    color: var(--text-muted);
}

.meta dd {
    min-width: 0;
}

.link-short {
    display: block;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.answer {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
}

.copy-btn {
    flex: none;
    width: 1.5rem;
    height: 1.5rem;
    padding: 0.2rem;
    background: transparent;
    border: none;
    border-radius: 4px;
    color: var(--text-muted);
    cursor: pointer;
}

.copy-btn svg {
    width: 100%;
    height: 100%;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

button.copy-btn:hover {
    color: var(--text);
    background: var(--border);
}

button.copy-btn.copied {
    color: var(--primary);
}

.upload-status {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.9rem;
}

.upload-status[hidden],
.upload-status progress[hidden] {
    display: none;
}

.upload-status progress {
    width: 12rem;
    accent-color: var(--primary);
}

/* Shared files */

.file-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.file-list li {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

/* Long file names are cut with an ellipsis, the button & size stay intact. */
.file-list li > * {
    flex: none;
    white-space: nowrap;
}

.file-list li > :not(.btn):not(.muted) {
    flex: 0 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Sizes form a right-aligned column. */
.file-list li > .muted {
    margin-left: auto;
    text-align: right;
}

.file-picker {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    padding: 0;
    border: none;
}

.file-picker legend {
    margin-bottom: 0.3rem;
    font-size: 0.9rem;
}

.public-share {
    max-width: 40rem;
    margin: 2rem auto;
}

.public-share-expiry {
    margin-top: 1.5rem;
    font-size: 0.85rem;
}

.errors {
    list-style: none;
    margin-bottom: 1rem;
    padding: 1rem 1.5rem;
    background: var(--error-bg);
    border-radius: 8px;
}

/* Split layout (sidebar left, content right) */

.split-layout {
    display: grid;
    grid-template-columns: minmax(20rem, 1fr) 2fr;
    gap: 1.5rem;
    align-items: start;
}

.split-layout > .card,
.split-content > .card:last-child {
    margin-bottom: 0;
}

.split-aside {
    position: sticky;
    top: 1rem;
}

@media (max-width: 1100px) {
    .split-layout {
        grid-template-columns: 1fr;
    }

    .split-aside {
        position: static;
    }
}

/* Editor */

#editor {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.section {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    padding: 1rem;
    border: 1px solid var(--border);
    border-radius: 8px;
}

.section-head {
    margin-bottom: 0.5rem;
}

.section-heading.input {
    flex: 1;
    padding-left: 0.25rem;
    background: transparent;
    border-color: transparent;
    font-size: 1.15rem;
    font-weight: 600;
}

.section-heading.input:hover, .section-heading.input:focus {
    border-color: var(--border);
}

.section-fields {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.field-choices.input {
    width: auto;
    margin-left: 2rem;
    font-size: 0.9rem;
}

.field-row {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.field-row .input:first-child {
    flex: 1;
}

.field-row select.input {
    width: auto;
}

.field-row .field-default {
    width: 12rem;
}

.field-row .field-default:disabled {
    opacity: 0.4;
}

.checkbox {
    flex-direction: row;
    align-items: center;
    white-space: nowrap;
}

/* Toasts */

.toast-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    z-index: 10;
}

.toast {
    padding: 0.75rem 1.25rem;
    border-radius: 6px;
    background: var(--surface);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    animation: toast 6s forwards;
}

.toast.error {
    background: var(--error-bg);
}

.toast.success {
    background: var(--success-bg);
}

@keyframes toast {
    0%, 85% { opacity: 1; }
    100% { opacity: 0; visibility: hidden; }
}

/* Mobile */

@media (max-width: 640px) {
    .welcome-card {
        flex-direction: column;
        gap: 1rem;
        padding: 2rem 1.25rem;
        text-align: center;
    }

    .welcome-avatar {
        height: 192px;
    }

    .field-row {
        flex-wrap: wrap;
    }

    .field-row .input:first-child {
        flex-basis: 100%;
    }

    .field-row select.input {
        flex: 1;
        min-width: 0;
    }

    .section-head {
        flex-wrap: nowrap;
    }

    .section-heading.input {
        min-width: 0;
    }

    .meta {
        grid-template-columns: 1fr;
    }

    .table th:nth-child(4), .table td:nth-child(4),
    .table th:nth-child(5), .table td:nth-child(5) {
        display: none;
    }
}
