/* ============================================
   나이스 도우미 — 사이드 패널 스타일 (v2)
   토큰: 인디고 그라디언트 포인트 + 기능별 컬러 칩,
   블루그레이 바탕 위 흰색 카드, 컴팩트 밀도
   ============================================ */

:root {
    --ink: #1f2430;
    --slate: #5a6472;
    --faint: #8b93a3;
    --line: #e4e6ee;
    --card: #ffffff;
    --panel-bg: #f7f8fc;
    --accent: #4f63d2;
    --accent-2: #7150c9;
    --accent-soft: #eef1fc;
    --accent-deep: #3a4cb0;
    --teal: #0f9d84;
    --teal-soft: #e4f5f0;
    --amber: #c07f16;
    --amber-soft: #fdf3e0;
    --rose: #d4526e;
    --rose-soft: #fdeef1;
    --success: #1b9e6d;
    --success-soft: #e2f6ee;
    --warn: #b97e12;
    --warn-soft: #fdf6e8;
    --error: #d43f3f;
    --error-soft: #fdecec;
}

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

body {
    font-family: "Apple SD Gothic Neo", "Pretendard", "Malgun Gothic", "Segoe UI", sans-serif;
    background: var(--panel-bg);
    color: var(--ink);
    font-size: 14px;
    line-height: 1.5;
    height: 100vh;
    overflow-y: auto;
    overflow-x: hidden;
}

button {
    font-family: inherit;
}

.hidden {
    display: none !important;
}

.spacer {
    flex: 1;
}

/* ---------- SVG 아이콘 ---------- */
svg.i {
    width: 16px;
    height: 16px;
    stroke: currentColor;
    fill: none;
    stroke-width: 1.7;
    stroke-linecap: round;
    stroke-linejoin: round;
    flex-shrink: 0;
}

svg.i.lg {
    width: 20px;
    height: 20px;
}

/* ---------- 컬러 아이콘 칩 ---------- */
.chip {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    display: grid;
    place-items: center;
    flex-shrink: 0;
}

.hue-indigo { background: var(--accent-soft); color: var(--accent); }
.hue-teal   { background: var(--teal-soft);   color: var(--teal); }
.hue-amber  { background: var(--amber-soft);  color: var(--amber); }
.hue-rose   { background: var(--rose-soft);   color: var(--rose); }

/* ---------- 뷰 전환 ---------- */
.view {
    display: none;
    flex-direction: column;
    min-height: 100vh;
}

.view.active {
    display: flex;
}

/* ---------- 헤더 ---------- */
header {
    background: linear-gradient(115deg, var(--accent) 0%, var(--accent-2) 100%);
    color: white;
    height: 48px;
    padding: 0 14px;
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

header h1 {
    font-size: 15px;
    font-weight: 700;
    flex: 1;
}

header .logo {
    width: 27px;
    height: 27px;
    border-radius: 8px;
    background: rgba(255, 255, 255, .18);
    border: 1px solid rgba(255, 255, 255, .28);
    display: grid;
    place-items: center;
    flex-shrink: 0;
}

.ghost-btn {
    width: 30px;
    height: 30px;
    border-radius: 8px;
    border: none;
    background: transparent;
    color: rgba(255, 255, 255, .9);
    display: grid;
    place-items: center;
    cursor: pointer;
    transition: background .15s;
    flex-shrink: 0;
}

.ghost-btn:hover {
    background: rgba(255, 255, 255, .16);
    color: #fff;
}

/* ---------- 본문 ---------- */
.page-body {
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    flex: 1;
}

section {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.sec-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11.5px;
    font-weight: 700;
    letter-spacing: .06em;
    color: var(--accent-deep);
}

.mini-btn {
    width: 24px;
    height: 24px;
    border-radius: 7px;
    background: var(--card);
    border: 1px solid var(--line);
    color: var(--slate);
    display: grid;
    place-items: center;
    cursor: pointer;
    transition: all .15s;
}

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

.mini-btn.primary {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.mini-btn.primary:hover {
    background: var(--accent-deep);
}

/* ---------- 포털 바로가기 ---------- */
.portal-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.portal-chip {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 46px;
    border: 1px solid var(--line);
    border-radius: 11px;
    background: var(--card);
    font-size: 13px;
    font-weight: 600;
    color: var(--ink);
    cursor: pointer;
    box-shadow: 0 1px 3px rgba(31, 36, 48, .05);
    transition: all .15s;
    padding: 0 4px;
}

.portal-chip .chip {
    width: 24px;
    height: 24px;
    border-radius: 7px;
}

.portal-chip:hover {
    border-color: var(--accent);
    background: var(--accent-soft);
}

/* ---------- 바로가기 목록 ---------- */
.shortcuts-list {
    display: flex;
    flex-direction: column;
    border: 1px solid var(--line);
    border-radius: 11px;
    overflow: hidden;
    background: var(--card);
    box-shadow: 0 1px 3px rgba(31, 36, 48, .05);
}

.shortcuts-list:empty {
    display: none;
}

.shortcut-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 10px 0 6px;
    height: 44px;
    background: var(--card);
    cursor: pointer;
    transition: background .15s;
}

.shortcut-item + .shortcut-item {
    border-top: 1px solid var(--line);
}

.shortcut-item:hover {
    background: var(--accent-soft);
}

.shortcut-item .drag-handle {
    cursor: grab;
    color: #c3c8d4;
    display: grid;
    place-items: center;
    user-select: none;
    transition: color .15s;
    flex-shrink: 0;
}

.shortcut-item .drag-handle:hover {
    color: var(--accent);
}

.shortcut-item .drag-handle:active {
    cursor: grabbing;
}

.shortcut-item .shortcut-info {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: baseline;
    gap: 8px;
    overflow: hidden;
}

.shortcut-item .shortcut-name {
    font-size: 13.5px;
    font-weight: 600;
    color: var(--ink);
    white-space: nowrap;
    flex-shrink: 0;
}

.shortcut-item .shortcut-path {
    font-size: 11px;
    color: var(--faint);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.shortcut-item .shortcut-actions {
    display: none;
    gap: 2px;
    flex-shrink: 0;
}

.shortcut-item:hover .shortcut-actions {
    display: flex;
}

.shortcut-item .shortcut-btn {
    background: transparent;
    border: none;
    color: var(--slate);
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
    display: grid;
    place-items: center;
    transition: all .15s;
}

.shortcut-item .shortcut-btn:hover {
    background: rgba(79, 99, 210, .12);
    color: var(--accent);
}

.shortcut-item .shortcut-btn.delete:hover {
    background: var(--error-soft);
    color: var(--error);
}

.shortcut-item .r-chev {
    color: var(--faint);
    flex-shrink: 0;
}

.shortcut-item:hover .r-chev {
    display: none;
}

.shortcut-item.dragging {
    opacity: .4;
}

/* ---------- 입력 도우미 그리드 ---------- */
.tool-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.tool-card {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 9px 11px;
    border: 1px solid var(--line);
    border-radius: 11px;
    background: var(--card);
    cursor: pointer;
    font-weight: 600;
    font-size: 13px;
    color: var(--ink);
    box-shadow: 0 1px 3px rgba(31, 36, 48, .05);
    transition: all .15s;
}

.tool-card:hover {
    border-color: var(--accent);
    background: var(--accent-soft);
}

/* ---------- 폼 ---------- */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.form-group label {
    font-size: 12.5px;
    font-weight: 700;
    color: var(--ink);
    display: flex;
    align-items: center;
    gap: 6px;
}

.label-hint {
    color: var(--faint);
    font-weight: 500;
}

.form-group input[type="text"],
.form-group input[type="url"],
.form-group textarea {
    width: 100%;
    padding: 9px 11px;
    border: 1px solid var(--line);
    border-radius: 9px;
    font-size: 13px;
    font-family: inherit;
    color: var(--ink);
    background: var(--card);
    transition: border-color .15s, box-shadow .15s;
    resize: vertical;
}

.form-group textarea {
    min-height: 96px;
    line-height: 1.5;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(79, 99, 210, .12);
}

.form-group input[type="file"] {
    width: 100%;
    padding: 8px;
    background: var(--card);
    border: 1px dashed var(--line);
    border-radius: 9px;
    cursor: pointer;
    font-size: 12.5px;
    color: var(--slate);
}

.form-group input[type="file"]:hover {
    border-color: var(--accent);
    background: var(--accent-soft);
}

.input-hint {
    font-size: 11.5px;
    color: var(--faint);
}

/* ---------- 세그먼트 컨트롤 ---------- */
.opt-line {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12.5px;
}

.opt-line .opt-name {
    font-weight: 700;
    color: var(--slate);
    width: 88px;
    flex-shrink: 0;
}

.seg {
    display: flex;
    border: 1px solid var(--line);
    border-radius: 8px;
    overflow: hidden;
    flex: 1;
    background: var(--card);
}

.seg-opt {
    flex: 1;
    cursor: pointer;
}

.seg-opt + .seg-opt {
    border-left: 1px solid var(--line);
}

.seg-opt input[type="radio"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.seg-opt span {
    display: block;
    text-align: center;
    padding: 6px 4px;
    font-size: 12px;
    font-weight: 600;
    color: var(--slate);
    transition: all .15s;
    white-space: nowrap;
}

.seg-opt:hover span {
    color: var(--accent);
}

.seg-opt input:checked + span {
    background: var(--accent);
    color: #fff;
}

.seg-opt input:focus-visible + span {
    outline: 2px solid var(--accent-deep);
    outline-offset: -2px;
}

/* ---------- 속도 인라인 표시 ---------- */
.speed-inline {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: 9px;
    background: var(--accent-soft);
    border: 1px solid #dfe4f8;
    font-size: 12px;
    color: var(--accent-deep);
    font-weight: 600;
}

.speed-inline strong {
    font-weight: 700;
}

.speed-inline-link {
    background: none;
    border: none;
    color: var(--accent);
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 4px;
}

.speed-inline-link:hover {
    background: rgba(79, 99, 210, .12);
}

/* ---------- 버튼 ---------- */
.primary-button {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    min-height: 42px;
    border: none;
    border-radius: 10px;
    background: linear-gradient(115deg, var(--accent), var(--accent-2));
    color: #fff;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 3px 10px rgba(79, 99, 210, .3);
    transition: filter .15s;
}

.primary-button:hover {
    filter: brightness(1.06);
}

.primary-button:disabled {
    filter: grayscale(.5) brightness(1.1);
    cursor: not-allowed;
    box-shadow: none;
}

.secondary-button {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    min-height: 42px;
    border-radius: 10px;
    border: 1px solid var(--line);
    background: var(--card);
    font-size: 14px;
    font-weight: 700;
    color: var(--slate);
    cursor: pointer;
    transition: all .15s;
}

.secondary-button:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.secondary-button:disabled {
    color: var(--faint);
    border-color: var(--line);
    cursor: not-allowed;
}

.btn-pair {
    display: flex;
    gap: 8px;
}

/* ---------- 안내 박스 ---------- */
.warn-note {
    display: flex;
    gap: 8px;
    padding: 9px 11px;
    border-radius: 9px;
    background: var(--warn-soft);
    border: 1px solid #f3e3bd;
    color: var(--warn);
    font-size: 12px;
    align-items: flex-start;
}

.warn-note svg {
    flex-shrink: 0;
    margin-top: 1px;
}

/* ---------- 진행 상황 ---------- */
.progress-line {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 12px;
    color: var(--slate);
}

.bar {
    flex: 1;
    height: 8px;
    border-radius: 4px;
    background: #e0e3ef;
    overflow: hidden;
}

.bar > div {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--accent), var(--accent-2));
    border-radius: 4px;
    transition: width .3s ease;
}

.progress-line .pct {
    font-variant-numeric: tabular-nums;
    font-weight: 700;
    color: var(--ink);
    white-space: nowrap;
}

/* ---------- 로그 ---------- */
.log-section {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1;
    min-height: 140px;
}

.log-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12.5px;
    font-weight: 700;
    color: var(--ink);
}

.clear-button {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 4px 10px;
    font-size: 11.5px;
    color: var(--slate);
    cursor: pointer;
    transition: all .15s;
}

.clear-button:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.log-container {
    flex: 1;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 9px;
    padding: 8px 10px;
    overflow-y: auto;
    max-height: 260px;
    font-size: 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.log-item {
    padding: 5px 8px;
    border-radius: 6px;
    border-left: 3px solid;
    background: var(--panel-bg);
    word-break: break-all;
}

.log-item.info {
    border-left-color: var(--accent);
    color: var(--slate);
}

.log-item.success {
    border-left-color: var(--success);
    background: var(--success-soft);
    color: #0c6b48;
}

.log-item.warning {
    border-left-color: var(--warn);
    background: var(--warn-soft);
    color: var(--warn);
}

.log-item.error {
    border-left-color: var(--error);
    background: var(--error-soft);
    color: #a32b2b;
}

/* ---------- 현재 학생 카드 (누가기록) ---------- */
.current-student-card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 11px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(31, 36, 48, .05);
}

.current-student-card .card-header {
    background: linear-gradient(115deg, var(--accent), var(--accent-2));
    color: white;
    padding: 9px 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.current-student-card .card-header h3 {
    font-size: 13.5px;
    font-weight: 700;
}

.current-student-card .student-progress {
    font-size: 12px;
    font-weight: 600;
    background: rgba(255, 255, 255, .2);
    padding: 2px 10px;
    border-radius: 20px;
    font-variant-numeric: tabular-nums;
}

.current-student-card .card-body {
    padding: 4px 14px;
}

.current-student-card .student-info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 7px 0;
}

.current-student-card .student-info-row + .student-info-row {
    border-top: 1px solid var(--panel-bg);
}

.current-student-card .info-label {
    font-size: 12.5px;
    color: var(--slate);
    font-weight: 500;
}

.current-student-card .info-value {
    font-size: 13.5px;
    color: var(--ink);
    font-weight: 700;
}

.current-student-card .card-actions {
    padding: 10px 14px;
    background: var(--panel-bg);
    display: flex;
    gap: 8px;
    border-top: 1px solid var(--line);
}

.current-student-card .card-actions button {
    flex: 1;
    min-height: 38px;
    font-size: 13px;
}

/* ---------- 설정: 속도 카드 ---------- */
.speed-card {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 11px;
    background: var(--card);
    box-shadow: 0 1px 3px rgba(31, 36, 48, .05);
}

.speed-card-head {
    display: flex;
    align-items: center;
    gap: 8px;
}

.speed-card-head .name {
    font-weight: 700;
    font-size: 13.5px;
    flex: 1;
}

.speed-card-head .val {
    font-size: 12px;
    font-weight: 700;
    color: #fff;
    background: linear-gradient(115deg, var(--accent), var(--accent-2));
    padding: 3px 10px;
    border-radius: 20px;
    white-space: nowrap;
}

.speed-range {
    width: 100%;
    accent-color: var(--accent);
    cursor: pointer;
}

.range-marks {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: var(--faint);
}

.speed-note {
    font-size: 11.5px;
    color: var(--faint);
}

/* ---------- 설정: URL 필드 ---------- */
.url-field label .chip {
    width: 20px;
    height: 20px;
    border-radius: 6px;
}

.url-field label .chip svg {
    width: 13px;
    height: 13px;
}

/* ---------- 설정 메시지 ---------- */
.settings-message {
    text-align: center;
    font-size: 13px;
    font-weight: 600;
    padding: 9px;
    border-radius: 9px;
}

.settings-message.success {
    background: var(--success-soft);
    color: #0c6b48;
    border: 1px solid #bfe8d6;
}

.settings-message.error {
    background: var(--error-soft);
    color: #a32b2b;
    border: 1px solid #f3c8c8;
}

/* ---------- 링크 행 (설정 하단) ---------- */
.link-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 12px 0 8px;
    height: 44px;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 11px;
    cursor: pointer;
    box-shadow: 0 1px 3px rgba(31, 36, 48, .05);
    transition: all .15s;
    font-size: 13.5px;
}

.link-row:hover {
    border-color: var(--accent);
    background: var(--accent-soft);
}

.link-row .r-name {
    font-weight: 600;
    color: var(--ink);
}

.link-row .r-chev {
    color: var(--faint);
}

/* ---------- 아이콘 선택기 (모달) ---------- */
.icon-picker {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 6px;
}

.icon-opt {
    aspect-ratio: 1;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--card);
    color: var(--slate);
    cursor: pointer;
    display: grid;
    place-items: center;
    transition: all .15s;
}

.icon-opt:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.icon-opt.selected {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

/* ---------- 모달 ---------- */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal.hidden {
    display: none;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(31, 36, 48, .5);
    backdrop-filter: blur(3px);
}

.modal-content {
    position: relative;
    background: var(--panel-bg);
    border-radius: 14px;
    width: 92%;
    max-width: 480px;
    max-height: 90vh;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(31, 36, 48, .3);
    animation: modalSlideIn .25s ease-out;
    display: flex;
    flex-direction: column;
}

@media (prefers-reduced-motion: reduce) {
    .modal-content {
        animation: none;
    }
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-16px) scale(.97);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.modal-header {
    background: linear-gradient(115deg, var(--accent), var(--accent-2));
    color: white;
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.modal-header h3 {
    font-size: 15px;
    font-weight: 700;
}

.modal-header .close-button {
    background: rgba(255, 255, 255, .18);
    border: none;
    color: white;
    width: 28px;
    height: 28px;
    border-radius: 8px;
    cursor: pointer;
    display: grid;
    place-items: center;
    transition: background .15s;
}

.modal-header .close-button:hover {
    background: rgba(255, 255, 255, .3);
}

.modal-body {
    padding: 16px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.modal-footer {
    padding: 12px 16px;
    background: var(--card);
    display: flex;
    gap: 8px;
    border-top: 1px solid var(--line);
    flex-shrink: 0;
}

.modal-footer .primary-button,
.modal-footer .secondary-button {
    flex: 1;
    min-height: 38px;
    font-size: 13.5px;
}

/* ---------- 푸터 ---------- */
footer {
    text-align: center;
    padding: 12px 10px 4px;
    margin-top: auto;
    color: var(--faint);
    font-size: 11px;
}
