html, body {
    height: 100%;
    margin: 0;
    font-family: 'Segoe UI', Roboto, 'Noto Sans KR', system-ui, -apple-system, 'Helvetica Neue', Arial;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body{
    background: linear-gradient(180deg, #070419 0%, #0b0626 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #222;
    min-height: 100vh;
}

.popup-overlay {
    position: fixed;
    inset: 0;
    background: rgba(5, 8, 20, 0.58);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.popup-overlay.show {
    opacity: 1;
    pointer-events: auto;
}

.popup {
    width: min(560px, calc(100vw - 32px));
    background: #fff;
    border-radius: 18px;
    box-shadow: 0 18px 50px rgba(2, 6, 23, 0.45);
    padding: 24px 24px 18px;
    border: 1px solid rgba(15, 23, 42, 0.08);
    transform: translateY(12px) scale(0.98);
    transition: transform 0.2s ease;
}

.permission-popup {
    width: min(460px, calc(100vw - 28px));
}

.permission-body {
    display: grid;
    gap: 12px;
}

.permission-url-list {
    display: grid;
    gap: 8px;
    padding: 12px 14px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    color: #334155;
    font-size: 0.8rem;
    word-break: break-all;
}

.permission-check-row {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #374151;
    font-size: 0.9rem;
}

.permission-check-row input {
    width: 18px;
    height: 18px;
    accent-color: #2563eb;
}

.permission-actions {
    justify-content: space-between;
    gap: 12px;
}

.btn.secondary {
    background: #fff;
    border: 1px solid #dfe8f3;
    color: #334155;
}

.popup-overlay.show .popup {
    transform: translateY(0) scale(1);
}

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

.popup-header h2 {
    margin: 0;
    font-size: 1.3rem;
    color: #0f172a;
}

.popup-close {
    border: 0;
    background: #f3f4f6;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    font-size: 1.4rem;
    cursor: pointer;
    color: #374151;
}

.popup-body {
    color: #374151;
    line-height: 1.7;
    max-height: 62vh;
    overflow-y: auto;
    padding-right: 6px;
}

.popup-body p {
    margin: 0 0 8px;
}

.help-copy {
    margin-bottom: 18px;
    padding-bottom: 12px;
    border-bottom: 1px solid #e5e7eb;
}

.legal-section {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 14px 16px;
}

.legal-section h3 {
    margin: 0 0 10px;
    font-size: 1rem;
    color: #0f172a;
}

.legal-section p {
    margin-bottom: 10px;
    font-size: 0.92rem;
}

.popup-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 18px;
}

.help-fab {
    position: fixed;
    right: 28px;
    bottom: 28px;
    width: 56px;
    height: 56px;
    border: none;
    border-radius: 50%;
    background: linear-gradient(135deg, #5b8cff 0%, #4ea0ff 100%);
    color: #fff;
    font-size: 1.8rem;
    font-weight: 700;
    box-shadow: 0 16px 30px rgba(78, 160, 255, 0.4);
    cursor: pointer;
    z-index: 900;
}

.help-fab:hover {
    filter: brightness(1.05);
}

.container{
    width: 100%;
    max-width: 920px;
    padding: 24px;
}

#maindiv.card{
    background-color: #ffffff;
    border-radius: 14px;
    box-shadow: 0 10px 30px rgba(3,6,23,0.6);
    padding: 36px;
    text-align: center;
}

h1{
    margin: 0 0 8px 0;
    font-size: 1.8rem;
    color: #0b1020;
}

.subtitle{
    margin: 0 0 20px 0;
    color: #6b7280;
}

.mode-switch {
    display: inline-flex;
    width: 100%;
    max-width: 280px;
    padding: 6px;
    border-radius: 999px;
    background: linear-gradient(180deg, #dfeeff 0%, #dbeafe 100%);
    box-shadow: inset 0 2px 6px rgba(59, 130, 246, 0.18);
    margin: 0 auto 18px;
    gap: 6px;
}

.mode-btn {
    flex: 1;
    border: none;
    border-radius: 999px;
    background: transparent;
    color: #3b4f72;
    font-weight: 700;
    font-size: 0.95rem;
    padding: 10px 16px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.mode-btn.active {
    background: linear-gradient(135deg, #3aa6ff 0%, #1d7ae5 100%);
    color: #fff;
    box-shadow: 0 8px 18px rgba(29, 122, 229, 0.28);
}

.panel {
    display: none;
}

.panel.active {
    display: block;
}

.download-box {
    width: 100%;
    max-width: 640px;
    margin: 0 auto;
}

.download-actions {
    margin-top: 8px;
}

.download-message {
    margin-top: 12px;
    min-height: 20px;
    font-weight: 600;
    display: none;
}

.download-message.visible {
    display: block;
}

.download-results {
    margin-top: 18px;
    display: none;
    overflow-x: auto;
}

.download-results.visible {
    display: block;
}

.download-toolbar {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 12px;
}

.bulk-delete-toolbar {
    display: flex;
    justify-content: flex-end;
    margin-top: 12px;
}

.bulk-delete-btn,
.download-all-btn,
.download-row-btn,
.delete-row-btn {
    display: inline-block;
    padding: 8px 14px;
    border: none;
    border-radius: 8px;
    background: linear-gradient(90deg, #5b8cff 0%, #4ea0ff 100%);
    color: #fff;
    font-weight: 700;
    cursor: pointer;
    text-decoration: none;
    font-size: 0.85rem;
    line-height: 1.2;
}

.bulk-delete-btn {
    background: linear-gradient(90deg, #ef4444 0%, #dc2626 100%);
}

.download-row-btn,
.delete-row-btn {
    padding: 7px 11px;
    font-size: 0.8rem;
}

.row-action-group {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.delete-row-btn {
    background: linear-gradient(90deg, #ef4444 0%, #dc2626 100%);
}

.download-table {
    width: 100%;
    border-collapse: collapse;
    background: #f9fbff;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid #dfeaf8;
}

.download-table th,
.download-table td {
    padding: 12px 14px;
    border-bottom: 1px solid #e5edf8;
    text-align: left;
    color: #25324a;
    font-size: 0.92rem;
    vertical-align: top;
}

.download-table th {
    background: #edf5ff;
    font-weight: 700;
}

.download-table tr:last-child td {
    border-bottom: none;
}

.file-drop{
    display: inline-flex;
    width: 100%;
    max-width: 640px;
    align-items: center;
    justify-content: center;
    border: 2px dashed #e6e9ef;
    padding: 28px;
    border-radius: 10px;
    cursor: pointer;
    background: linear-gradient(180deg, #fafbff 0%, #f6f8ff 100%);
    position: relative;
}

.file-drop input[type="file"]{
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

.file-drop.dragover{
    border-color: #4ea0ff;
    background: linear-gradient(180deg, #eef6ff 0%, #f6fbff 100%);
    box-shadow: 0 6px 18px rgba(78,160,255,0.12);
}

.file-label{
    color: #374151;
    font-weight: 600;
}

.field{
    margin-bottom: 14px;
}

.file-memo-list {
    display: none;
    width: 100%;
    max-width: 640px;
    margin: 12px auto 0;
    gap: 10px;
}

.file-memo-list.visible {
    display: grid;
}

.file-memo-item {
    display: grid;
    grid-template-columns: 140px 1fr;
    gap: 8px;
    align-items: center;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 8px 10px;
}

.file-memo-item span {
    font-size: 0.8rem;
    color: #475569;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-memo-item input {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #dbe4f1;
    border-radius: 6px;
    font-size: 0.85rem;
    box-sizing: border-box;
}

.download-username-field {
    position: relative;
    max-width: 640px;
    margin: 0 auto 14px;
}

.text-input{
    width: 100%;
    max-width: 640px;
    padding: 10px 12px;
    border-radius: 8px;
    border: 1px solid #e6e9ef;
    font-size: 0.95rem;
    box-sizing: border-box;
}

.clear-download-history-btn {
    position: absolute;
    top: 50%;
    right: 4px;
    transform: translateY(-50%);
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: #64748b;
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
}

.clear-download-history-btn:hover {
    background: rgba(148, 163, 184, 0.12);
    color: #0f172a;
}

.actions{
    margin-top: 18px;
    display: flex;
    gap: 12px;
    justify-content: center;
}

.btn{
    padding: 10px 18px;
    border-radius: 8px;
    border: 1px solid rgba(11,16,32,0.08);
    background: #fff;
    cursor: pointer;
}

.btn.primary{
    background: linear-gradient(90deg, #5b8cff 0%, #4ea0ff 100%);
    color: white;
    border: none;
}

.message{
    margin-top: 12px;
    min-height: 20px;
    font-weight: 600;
}

.note{
    margin-top: 12px;
    color: #c7c9d8;
    text-align: center;
}