:root {
    --primary: #07c160;
    --primary-dark: #06ad56;
    --primary-light: rgba(7, 193, 96, 0.12);
    --bg: #ededed;
    --card: #ffffff;
    --text: #1a1a1a;
    --text-secondary: #888888;
    --border: #d8d8d8;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    --danger: #ff4d4f;
    --warning: #faad14;
}

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

html, body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans SC", sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
}

.app {
    max-width: 768px;
    margin: 0 auto;
    height: 100%;
    display: flex;
    flex-direction: column;
    background: var(--bg);
}

.view.hidden {
    display: none;
}

.view {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow-y: auto;
    padding: 16px;
    gap: 16px;
}

/* ---------- header ---------- */

.page-header {
    background: var(--card);
    border-bottom: 1px solid var(--border);
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.back-link {
    color: var(--primary);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
}

.page-header h1 {
    font-size: 17px;
    font-weight: 600;
    flex: 1;
    text-align: center;
    margin-right: 40px;
}

/* ---------- pin view ---------- */

.pin-card {
    margin: auto 24px;
    background: var(--card);
    border-radius: 16px;
    padding: 32px 24px;
    box-shadow: var(--shadow);
    text-align: center;
}

.pin-hint {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 20px;
}

.pin-card input {
    width: 100%;
    font-size: 32px;
    letter-spacing: 8px;
    text-align: center;
    font-weight: 600;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: 12px;
    margin-bottom: 16px;
    font-family: "SF Mono", Monaco, "Courier New", monospace;
    outline: none;
}

.pin-card input:focus {
    border-color: var(--primary);
}

.pin-note {
    color: var(--text-secondary);
    font-size: 12px;
    margin-top: 12px;
}

.primary-btn {
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: 8px;
    background: var(--primary);
    color: #fff;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}

.primary-btn:hover {
    background: var(--primary-dark);
}

.primary-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
}

/* ---------- capacity ---------- */

.capacity-bar {
    height: 8px;
    background: #e0e0e0;
    border-radius: 4px;
    overflow: hidden;
}

.capacity-fill {
    height: 100%;
    width: 0%;
    background: var(--primary);
    transition: width 0.3s;
}

.capacity-text {
    font-size: 13px;
    color: var(--text-secondary);
    text-align: right;
}

/* ---------- upload section ---------- */

.upload-section {
    background: var(--card);
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow);
}

.upload-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 14px;
}

.tab-btn {
    flex: 1;
    padding: 10px;
    border: 1px solid var(--border);
    background: var(--card);
    border-radius: var(--radius);
    font-size: 15px;
    cursor: pointer;
}

.tab-btn.active {
    border-color: var(--primary);
    background: var(--primary-light);
    color: var(--primary);
    font-weight: 500;
}

.upload-panel {
    display: none;
}

.upload-panel.active {
    display: block;
}

textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 15px;
    font-family: inherit;
    resize: vertical;
    outline: none;
    margin-bottom: 12px;
}

textarea:focus {
    border-color: var(--primary);
}

.drop-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 32px 16px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--text-secondary);
    font-size: 14px;
    outline: none;
}

.drop-zone:hover,
.drop-zone.active,
.drop-zone:focus {
    border-color: var(--primary);
    background: var(--primary-light);
    color: var(--text);
}

.drop-zone .hint {
    font-size: 12px;
    margin-top: 6px;
}

.uploading-files {
    margin-top: 12px;
    padding: 12px;
    background: var(--primary-light);
    color: var(--primary);
    border-radius: 8px;
    text-align: center;
    font-size: 14px;
}

/* ---------- items ---------- */

.items-section {
    background: var(--card);
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow);
    flex: 1;
}

.items-section h2 {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 12px;
}

.items-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.empty {
    text-align: center;
    color: var(--text-secondary);
    font-size: 14px;
    padding: 24px;
}

.item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: #f9f9f9;
    border-radius: 8px;
}

.item-icon {
    font-size: 28px;
    flex-shrink: 0;
}

.item-info {
    flex: 1;
    min-width: 0;
}

.item-name {
    font-weight: 500;
    font-size: 14px;
    word-break: break-all;
}

.item-meta {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 2px;
}

.item-text-preview {
    font-size: 14px;
    color: var(--text);
    word-break: break-all;
    white-space: pre-wrap;
}

.item-image-preview {
    margin-bottom: 8px;
}

.storage-thumb {
    max-width: 140px;
    max-height: 140px;
    border-radius: 6px;
    cursor: pointer;
    display: block;
    object-fit: cover;
    border: 1px solid var(--border);
}

.lightbox {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 500;
    cursor: zoom-out;
}

.lightbox img {
    max-width: 95%;
    max-height: 95%;
    object-fit: contain;
}

.lightbox.hidden {
    display: none;
}

.item-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

.icon-btn {
    padding: 8px 12px;
    border: none;
    border-radius: 6px;
    background: #e8e8e8;
    font-size: 13px;
    cursor: pointer;
    color: var(--text);
}

.icon-btn:hover {
    background: #ddd;
}

.icon-btn.danger {
    background: #ffe6e6;
    color: var(--danger);
}

.icon-btn.danger:hover {
    background: #ffd6d6;
}

/* ---------- drop overlay ---------- */

.drop-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
}

.drop-overlay.hidden {
    display: none;
}

.drop-overlay-box {
    width: 220px;
    height: 220px;
    border: 3px dashed #fff;
    border-radius: 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #fff;
    text-align: center;
}

.drop-overlay-icon {
    font-size: 64px;
    margin-bottom: 12px;
}

.drop-overlay-text {
    font-size: 18px;
    font-weight: 500;
}

/* ---------- toast ---------- */

.toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.8);
    color: #fff;
    padding: 10px 20px;
    border-radius: 24px;
    font-size: 14px;
    z-index: 300;
    transition: opacity 0.3s;
    max-width: 90%;
    text-align: center;
}

.toast.hidden {
    opacity: 0;
    pointer-events: none;
}

.hidden {
    display: none !important;
}

@media (min-width: 769px) {
    body {
        background: #e5e5e5;
    }

    .app {
        border-left: 1px solid var(--border);
        border-right: 1px solid var(--border);
    }
}
