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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
}

.hidden {
    display: none !important;
}

/* パスワードダイアログ */
.dialog-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.dialog-box {
    background: white;
    padding: 40px;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    text-align: center;
    max-width: 400px;
    width: 90%;
}

.dialog-box h2 {
    margin-bottom: 20px;
    color: #333;
}

.dialog-box input {
    width: 100%;
    padding: 12px;
    margin-bottom: 15px;
    border: 2px solid #ddd;
    border-radius: 6px;
    font-size: 16px;
}

.dialog-box button {
    width: 100%;
    padding: 12px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 16px;
    cursor: pointer;
    transition: background 0.3s;
}

.dialog-box button:hover {
    background: #5568d3;
}

.error {
    color: #e74c3c;
    margin-top: 10px;
    font-size: 14px;
}

/* メインコンテンツ */
.container {
    max-width: 800px;
    margin: 0 auto;
}

h1 {
    color: white;
    text-align: center;
    margin-bottom: 30px;
    font-size: 2.5em;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
}

/* リンク登録フォーム */
.add-link-form {
    background: white;
    padding: 30px;
    border-radius: 12px;
    margin-bottom: 30px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.1);
}

.add-link-form h2 {
    color: #333;
    margin-bottom: 20px;
    font-size: 1.5em;
}

.form-group {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: flex-end;
}

.input-wrapper {
    flex: 1;
    min-width: 200px;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.input-wrapper label {
    font-size: 14px;
    font-weight: bold;
    color: #495057;
}

.input-wrapper input {
    padding: 12px;
    border: 2px solid #ddd;
    border-radius: 6px;
    font-size: 16px;
}

.input-wrapper input:focus {
    outline: none;
    border-color: #667eea;
}

.form-group button {
    padding: 12px 30px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 16px;
    cursor: pointer;
    transition: background 0.3s;
    align-self: flex-end;
}

.form-group button:hover {
    background: #5568d3;
}

/* リンク一覧 */
.links-section {
    background: white;
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.1);
}

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

.links-section h2 {
    color: #333;
    margin: 0;
    font-size: 1.5em;
}

.btn-clear-all {
    padding: 8px 20px;
    background: #dc3545;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.3s;
}

.btn-clear-all:hover {
    background: #c82333;
}

.links-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.link-item {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 8px;
    border: 2px solid #e9ecef;
    transition: transform 0.2s, box-shadow 0.2s, opacity 0.2s;
    display: flex;
    gap: 15px;
    cursor: move;
}

.link-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.link-item.dragging {
    opacity: 0.5;
    transform: rotate(2deg);
}

.link-item.drag-over {
    border-color: #667eea;
    background: #e9ecf8;
}

.drag-handle {
    font-size: 20px;
    color: #999;
    cursor: move;
    user-select: none;
    display: flex;
    align-items: center;
    padding: 0 5px;
    font-weight: bold;
    letter-spacing: -2px;
}

.drag-handle:hover {
    color: #667eea;
}

.link-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.link-info {
    margin-bottom: 0;
}

.link-name {
    font-size: 1.2em;
    font-weight: bold;
    color: #333;
    margin-bottom: 5px;
}

.link-url {
    color: #667eea;
    font-size: 0.9em;
    word-break: break-all;
}

.link-actions {
    display: flex;
    gap: 10px;
}

.link-actions button {
    flex: 1;
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-visit {
    background: #28a745;
    color: white;
}

.btn-visit:hover {
    background: #218838;
}

.btn-qr {
    background: #667eea;
    color: white;
}

.btn-qr:hover {
    background: #5568d3;
}

.btn-move-up,
.btn-move-down {
    background: #6c757d;
    color: white;
    min-width: 40px;
    font-size: 16px;
    font-weight: bold;
}

.btn-move-up:hover:not(:disabled),
.btn-move-down:hover:not(:disabled) {
    background: #5a6268;
}

.btn-move-up:disabled,
.btn-move-down:disabled {
    background: #d6d8db;
    color: #6c757d;
    cursor: not-allowed;
    opacity: 0.5;
}

.btn-delete {
    background: #dc3545;
    color: white;
}

.btn-delete:hover {
    background: #c82333;
}

/* QRコードモーダル */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
}

.modal-box {
    background: white;
    padding: 40px;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    text-align: center;
    max-width: 400px;
}

.modal-box h2 {
    margin-bottom: 20px;
    color: #333;
}

#qrcode {
    margin: 20px 0;
    display: flex;
    justify-content: center;
}

.modal-box button {
    padding: 12px 30px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 16px;
    cursor: pointer;
    transition: background 0.3s;
}

.modal-box button:hover {
    background: #5568d3;
}

/* カスタムダイアログのボタングループ */
.dialog-box p {
    margin-bottom: 20px;
    color: #333;
    font-size: 16px;
}

.confirm-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.confirm-buttons button {
    flex: 1;
    padding: 12px 20px;
    border: none;
    border-radius: 6px;
    font-size: 16px;
    cursor: pointer;
    transition: background 0.3s;
}

.btn-confirm {
    background: #28a745;
    color: white;
}

.btn-confirm:hover {
    background: #218838;
}

.btn-cancel {
    background: #6c757d;
    color: white;
}

.btn-cancel:hover {
    background: #5a6268;
}

/* ローディングスピナー */
.loading-spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

#loadingMessage {
    margin: 0;
    color: #333;
    font-size: 16px;
}

/* レスポンシブ対応 */
@media (max-width: 600px) {
    h1 {
        font-size: 2em;
    }

    .form-group {
        flex-direction: column;
    }

    .input-wrapper {
        width: 100%;
    }

    .form-group button {
        width: 100%;
    }

    .section-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }

    .btn-clear-all {
        width: 100%;
    }

    .link-item {
        flex-direction: column;
        gap: 10px;
    }

    .drag-handle {
        text-align: center;
        padding: 5px;
        border-bottom: 2px solid #e9ecef;
    }

    .link-actions {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }

    .btn-move-up,
    .btn-move-down {
        grid-column: span 1;
    }

    .btn-visit,
    .btn-qr {
        grid-column: span 1;
    }

    .btn-delete {
        grid-column: span 2;
    }
}
