@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600&display=swap');

:root {
    --bg: #fafafa;
    --surface: #fff;
    --text: #1a1a1a;
    --text-2: #666;
    --text-3: #999;
    --border: #e8e8e8;
    --primary: #1a1a1a;
    --accent: #2563eb;
    --error: #c0392b;
    --success: #27ae60;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'DM Sans', system-ui, sans-serif;
}

body {
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
}

.container {
    max-width: 720px;
    margin: 0 auto;
    padding: 20px;
    overflow-x: hidden;
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 24px;
    margin-bottom: 16px;
    overflow-wrap: break-word;
    word-break: break-word;
}

.text-center { text-align: center; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mb-1 { margin-bottom: 8px; }

h1 { font-size: 1.25rem; font-weight: 600; color: var(--text); margin-bottom: 4px; overflow-wrap: break-word; word-break: break-word; }
h2 { font-size: 1.05rem; font-weight: 600; color: var(--text); margin-bottom: 8px; overflow-wrap: break-word; word-break: break-word; }
h3 { font-size: 0.9rem; font-weight: 600; color: var(--text); margin-bottom: 8px; overflow-wrap: break-word; word-break: break-word; }

p { color: var(--text-2); font-size: 13px; overflow-wrap: break-word; word-break: break-word; }

.form-group { margin-bottom: 14px; }

label {
    display: block;
    margin-bottom: 4px;
    font-weight: 500;
    font-size: 13px;
    color: var(--text);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="datetime-local"],
textarea,
select {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--surface);
    font-size: 14px;
    color: var(--text);
    transition: border-color 0.15s;
}

input:focus, textarea:focus {
    outline: none;
    border-color: var(--accent);
}

input[type="file"] {
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: 4px;
    width: 100%;
    cursor: pointer;
    font-size: 13px;
    background: var(--bg);
}

.btn {
    display: inline-block;
    padding: 8px 16px;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 500;
    font-size: 13px;
    transition: opacity 0.15s;
    text-decoration: none;
    text-align: center;
    width: 100%;
}

.btn-inline { width: auto; }
.btn:hover { opacity: 0.85; }
.btn:active { opacity: 0.75; }

.btn-accent { background: var(--accent); }
.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
}
.btn-outline:hover { border-color: var(--text); }
.btn-danger { background: var(--error); }
.btn-danger:hover { opacity: 0.85; }

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

.task-list { display: grid; gap: 8px; }

.task-item {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 14px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    transition: border-color 0.15s;
}

.task-item:hover { border-color: var(--text-3); }
.task-info h3 { margin-bottom: 2px; font-size: 14px; }
.task-info p { font-size: 12px; color: var(--text-3); }

.table-container { overflow-x: auto; max-width: 100%; }

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

th, td {
    padding: 8px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
    overflow-wrap: break-word;
    word-break: break-word;
    max-width: 200px;
}

th {
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-3);
}

.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.3);
    align-items: center;
    justify-content: center;
    z-index: 1000;
}
.modal.active { display: flex; }

.modal-content {
    background: var(--surface);
    padding: 24px;
    border-radius: 6px;
    width: 90%;
    max-width: 440px;
    max-height: 90vh;
    overflow-y: auto;
    overflow-wrap: break-word;
    word-break: break-word;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.close-btn {
    background: none;
    border: none;
    font-size: 1.1rem;
    cursor: pointer;
    color: var(--text-3);
    padding: 2px 6px;
}
.close-btn:hover { color: var(--text); }

.loader {
    border: 2px solid var(--border);
    border-top: 2px solid var(--text);
    border-radius: 50%;
    width: 20px;
    height: 20px;
    animation: spin 0.7s linear infinite;
    margin: 16px auto;
}
@keyframes spin {
    to { transform: rotate(360deg); }
}

.hidden { display: none !important; }
.empty-state { text-align: center; padding: 32px; color: var(--text-3); font-size: 13px; }

#toast-container {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.toast {
    background: var(--text);
    color: #fff;
    padding: 10px 16px;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 500;
    opacity: 0;
    transform: translateY(-8px);
    transition: opacity 0.15s, transform 0.15s;
    max-width: 320px;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.success { border-left: 3px solid var(--success); }
.toast.error { border-left: 3px solid var(--error); }
.toast.info { border-left: 3px solid var(--accent); }

/* Storage bar */
.storage-bar {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 12px 16px;
    margin-bottom: 16px;
}
.storage-track {
    width: 100%;
    height: 6px;
    background: var(--bg);
    border-radius: 3px;
    overflow: hidden;
    border: 1px solid var(--border);
}
.storage-fill {
    height: 100%;
    border-radius: 3px;
    background: var(--accent);
    transition: width 0.5s ease, background 0.3s;
}
.storage-fill.warning { background: #e67e22; }
.storage-fill.danger { background: var(--error); }
.storage-warning {
    margin-top: 8px;
    padding: 8px 10px;
    border-radius: 4px;
    font-size: 12px;
    line-height: 1.5;
    color: #92400e;
    background: #fef3c7;
    border: 1px solid #f59e0b;
}
.storage-warning.danger {
    color: #7f1d1d;
    background: #fee2e2;
    border-color: var(--error);
}

@media (max-width: 640px) {
    .container { padding: 14px; }
    .card { padding: 16px; }
    .header { flex-direction: column; align-items: flex-start; gap: 8px; }
    th, td { padding: 6px 8px; font-size: 12px; }
}

/* Flatpickr overrides */
.flatpickr-calendar {
    font-family: 'DM Sans', system-ui, sans-serif;
    border: 1px solid var(--border);
    box-shadow: 0 2px 12px rgba(0,0,0,0.08);
    border-radius: 6px;
}
.flatpickr-day.selected,
.flatpickr-day.selected:hover {
    background: #1a1a1a;
    border-color: #1a1a1a;
}
.flatpickr-day:hover {
    background: #f0f0f0;
    border-color: #f0f0f0;
}
.flatpickr-months .flatpickr-month {
    height: 36px;
}

/* Select dropdown */
select {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--surface);
    font-size: 14px;
    color: var(--text);
    transition: border-color 0.15s;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%23666' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
}
select:focus {
    outline: none;
    border-color: var(--accent);
}

/* Type picker buttons */
.type-picker {
    display: flex;
    gap: 6px;
}
.type-picker-btn {
    flex: 1;
    padding: 10px 8px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--surface);
    color: var(--text-2);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    text-align: center;
    font-family: inherit;
}
.type-picker-btn:hover {
    border-color: var(--text-3);
}
.type-picker-btn.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

/* Media preview (video/audio) */
.media-preview-item {
    position: relative;
    width: 80px;
    height: 80px;
    border-radius: 4px;
    overflow: hidden;
    border: 1px solid var(--border);
    cursor: pointer;
    background: #f0f0f0;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.media-preview-item video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.media-preview-item .media-icon {
    font-size: 24px;
    color: var(--text-3);
}
.media-preview-item .media-label {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0,0,0,0.55);
    color: white;
    font-size: 9px;
    text-align: center;
    padding: 1px 0;
}
.media-preview-item .media-remove {
    position: absolute;
    top: 2px;
    right: 2px;
    background: #1a1a1a;
    color: white;
    border: none;
    border-radius: 2px;
    width: 16px;
    height: 16px;
    font-size: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1;
}
.media-preview-item .play-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.2);
    pointer-events: none;
}
.media-preview-item .play-overlay::after {
    content: '▶';
    color: white;
    font-size: 18px;
    text-shadow: 0 1px 4px rgba(0,0,0,0.5);
}

/* Submission type badge */
.type-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border-radius: 3px;
    font-size: 11px;
    font-weight: 500;
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--text-2);
}

/* Audio player inline */
.audio-player-inline {
    width: 100%;
    height: 36px;
    border-radius: 4px;
}

/* Media viewer overlay */
.media-viewer-item {
    margin-bottom: 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    overflow: hidden;
}
.media-viewer-item video,
.media-viewer-item audio {
    width: 100%;
    display: block;
}
.media-viewer-item .media-viewer-caption {
    font-size: 12px;
    color: var(--text-3);
    padding: 8px 12px;
    text-align: center;
    border-top: 1px solid var(--border);
}
