* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
    font: 13px/1.4 -apple-system, BlinkMacSystemFont, 'Helvetica Neue', sans-serif;
    color: #222;
    background: #fafafa;
}
button, select, input, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.muted { color: #999; }
.small { font-size: 12px; }
.link, .link-btn { color: #0011ff; cursor: pointer; }
.link-btn { border: 0; background: none; padding: 0; }
.link-btn:hover, .link:hover { text-decoration: underline; }

.btn {
    display: inline-block; border: 1px solid #ddd; background: #fff; border-radius: 6px;
    padding: 6px 12px; cursor: pointer; text-decoration: none; color: #222;
}
.btn:hover { border-color: #999; }
.btn--primary { background: #222; border-color: #222; color: #fff; }
.btn--primary:hover { background: #000; }
.btn--primary:disabled { background: #bbb; border-color: #bbb; cursor: default; }
.btn--sm { padding: 3px 9px; }
.btn--block { display: block; width: 100%; padding: 9px 12px; }

/* Login */
.login {
    min-height: 100vh; display: flex; flex-direction: column;
    align-items: center; justify-content: center; gap: 16px; text-align: center;
}
.login__hi { margin: 0; font-size: 15px; color: #222; }
.login .btn { padding: 9px 18px; }

/* App shell */
.app { display: flex; flex-direction: column; height: 100vh; }
.top {
    flex: none; display: flex; align-items: center; gap: 14px;
    height: 48px; padding: 0 16px; background: #fff; border-bottom: 1px solid #e6e6e6;
}
.top__title { font-weight: 600; }
.top__spacer { flex: 1; }
.top__link { color: #999; text-decoration: none; }
.top__link:hover { color: #222; }
.tabs { display: flex; gap: 4px; }
.tab { border: 0; background: none; padding: 6px 10px; border-radius: 6px; cursor: pointer; color: #777; }
.tab:hover { color: #222; }
.tab.is-active { background: #f0f0f0; color: #000; }
.banner {
    display: flex; align-items: center; gap: 8px; padding: 4px 6px 4px 12px;
    background: #fff6d6; border: 1px solid #f0dc8f; border-radius: 8px;
}

.view { flex: 1; min-height: 0; display: none; }
.view.is-active { display: flex; }
.view--scroll { overflow-y: auto; }

/* Sidebar */
.side {
    width: 300px; flex: none; overflow-y: auto; padding: 16px 16px 60px;
    background: #fff; border-right: 1px solid #e6e6e6; user-select: none;
}
.progress__bar { height: 4px; background: #eee; border-radius: 2px; overflow: hidden; }
.progress__bar span { display: block; height: 100%; width: 0; background: #222; transition: width .2s; }
#progress-text { margin-top: 6px; }
.sel { margin: 16px 0 6px; padding: 10px; background: #f5f5f5; border-radius: 8px; }
.sel__count { font-weight: 600; margin-bottom: 8px; }
.sel__actions { display: flex; gap: 6px; flex-wrap: wrap; }
.sel__actions button, .post__btn {
    border: 1px solid #ddd; background: #fff; border-radius: 6px; padding: 4px 9px; cursor: pointer;
}
.sel__actions button:hover, .post__btn:hover { border-color: #999; }

.group { margin-top: 18px; }
.group__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.group__title { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: #888; }
.group__add { border: 0; background: none; color: #0011ff; cursor: pointer; padding: 0; }
.add-form { display: flex; gap: 6px; margin-bottom: 8px; }
.add-form input { flex: 1; min-width: 0; padding: 4px 8px; border: 1px solid #bbb; border-radius: 6px; }
.add-form button { border: 1px solid #ddd; background: #fff; border-radius: 6px; padding: 4px 9px; cursor: pointer; }
.add-form button[type="submit"] { background: #222; color: #fff; border-color: #222; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
    position: relative; border: 1px solid #ddd; background: #fff; border-radius: 999px;
    padding: 5px 11px; cursor: pointer;
}
.chip:hover { border-color: #888; }
.chip--cat { border-style: dashed; color: #666; }
.chip.is-all { background: #222; border-color: #222; color: #fff; }
.chip.is-some { background: #e8e8e8; border-color: #bbb; }
.chip:disabled { opacity: .45; cursor: default; }
.chip__key {
    position: absolute; top: -6px; right: -4px; font-size: 9px; line-height: 14px; width: 14px;
    text-align: center; background: #0011ff; color: #fff; border-radius: 50%;
}

.filters { margin-top: 22px; display: grid; gap: 8px; }
.filters label { display: flex; justify-content: space-between; align-items: center; gap: 8px; color: #666; }
.filters select { width: 170px; }
.help { margin-top: 20px; color: #666; }
.help summary { cursor: pointer; }
.help dl { display: grid; grid-template-columns: auto 1fr; gap: 3px 10px; margin: 8px 0 0; }
.help dt { font-weight: 600; color: #333; }
.help dd { margin: 0; }
.save { margin-top: 16px; }

/* Contact sheet */
.sheet { flex: 1; min-width: 0; overflow-y: auto; padding: 18px 24px 50vh; position: relative; }
.post { margin-bottom: 24px; background: #fff; border: 1px solid #eee; border-radius: 10px; padding: 12px 14px 14px; }
.post.is-current { border-color: #bbb; }
.post.is-reviewed { opacity: .55; }
.post.is-reviewed:hover, .post.is-reviewed.is-current { opacity: 1; }
.post__head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.post__date { font-weight: 600; }
.post__link { color: #999; text-decoration: none; }
.post__link:hover { color: #0011ff; }
.post__state { font-size: 11px; padding: 1px 6px; border-radius: 4px; background: #eef; color: #335; }
.post__count { color: #999; margin-left: auto; }
.post__btn.is-on { background: #222; color: #fff; border-color: #222; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: transparent; flex: none; }
.dot.is-saving { background: #f0b400; }
.dot.is-saved { background: #3bb273; }
.dot.is-error { background: #e5484d; }
.post__legacy { color: #999; }

.photos { display: flex; flex-wrap: wrap; gap: 8px; }
.photo {
    position: relative; height: 150px; border-radius: 4px; overflow: hidden; cursor: pointer;
    outline: 3px solid transparent; outline-offset: 1px; background: #eee;
}
.photo img { height: 100%; width: 100%; display: block; object-fit: cover; pointer-events: none; -webkit-user-drag: none; }
.photo.is-selected { outline-color: #0011ff; }
.photo.is-selected::after { content: ''; position: absolute; inset: 0; background: rgba(0, 17, 255, .12); }
.photo__tags { position: absolute; left: 4px; right: 4px; bottom: 4px; display: flex; flex-wrap: wrap; gap: 3px; pointer-events: none; }
.photo__tag { font-size: 10px; line-height: 1; padding: 3px 5px; border-radius: 3px; background: rgba(255, 255, 255, .92); color: #222; }
.photo__tag--people { background: #fde6ef; }
.photo__tag--travel { background: #e2f0e6; }
.photo__tag--series { background: #e4e8fb; }

/* New post */
.compose { margin-top: 22px; display: grid; gap: 6px; }
.compose__label { margin-top: 6px; color: #666; }
.compose textarea, .compose select, .compose input { width: 100%; padding: 6px 8px; border: 1px solid #ddd; border-radius: 6px; background: #fff; }
.compose .btn--block { margin-top: 10px; }
.drop {
    display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 28px;
    border: 2px dashed #ccc; border-radius: 12px; background: #fff; text-align: center; cursor: pointer;
}
.drop.is-over { border-color: #0011ff; background: #f3f4ff; }
.new-grid { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }
.new-grid .photo { height: 180px; }
.photo__remove {
    position: absolute; top: 4px; right: 4px; z-index: 2; width: 22px; height: 22px; border: 0; border-radius: 50%;
    background: rgba(0, 0, 0, .55); color: #fff; cursor: pointer; line-height: 22px; padding: 0;
}
.photo__status {
    position: absolute; top: 4px; left: 4px; z-index: 2; font-size: 10px; padding: 3px 6px; border-radius: 3px;
    background: rgba(0, 0, 0, .55); color: #fff;
}
.photo__status.is-error { background: #e5484d; }
.photo.is-dragging { opacity: .4; }
.photo.is-drop-before { box-shadow: -6px 0 0 -2px #0011ff; }

/* Lists & covers */
.lists { width: 100%; max-width: 1200px; margin: 0 auto; padding: 24px 24px 120px; }
.list-section { margin-bottom: 40px; }
.list-section__head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 14px; }
.list-section__head h2 { font-size: 16px; margin: 0; }
.list-section__head .link-btn { margin-left: auto; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; }
.tile { background: #fff; border: 1px solid #eee; border-radius: 10px; padding: 8px; cursor: grab; }
.tile.is-dragging { opacity: .4; }
.tile.is-drop-before { box-shadow: -8px 0 0 -4px #0011ff; }
.tile__cover { aspect-ratio: 3 / 2; border-radius: 6px; overflow: hidden; background: #e9dfd3; display: flex; align-items: center; justify-content: center; color: #998; }
.tile__cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tile__meta { display: flex; align-items: baseline; gap: 8px; margin-top: 8px; }
.tile__label { font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile__actions { display: flex; gap: 10px; margin-top: 6px; flex-wrap: wrap; }
.people-list { list-style: none; padding: 0; margin: 0; columns: 3 260px; column-gap: 24px; }
.people-list li { break-inside: avoid; display: flex; align-items: baseline; gap: 8px; padding: 5px 0; border-bottom: 1px solid #f0f0f0; }
.people-list .p-label { flex: 1; }
.people-list .p-tag { color: #aaa; font-size: 11px; }
.inline-edit { padding: 2px 6px; border: 1px solid #bbb; border-radius: 4px; width: 100%; }

/* Modal (cover picker) */
.modal { position: fixed; inset: 0; z-index: 30; background: rgba(0, 0, 0, .35); display: flex; align-items: center; justify-content: center; padding: 24px; }
.modal__box { background: #fff; border-radius: 12px; width: min(1000px, 100%); max-height: 100%; display: flex; flex-direction: column; }
.modal__head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid #eee; }
.modal__head h3 { margin: 0; font-size: 15px; }
.modal__body { overflow-y: auto; padding: 18px; }
.picker { display: flex; flex-wrap: wrap; gap: 8px; }
.picker button { padding: 0; border: 3px solid transparent; border-radius: 6px; overflow: hidden; height: 140px; cursor: pointer; background: #eee; }
.picker button img { height: 100%; display: block; }
.picker button:hover { border-color: #999; }
.picker button.is-current { border-color: #0011ff; }

.lasso { position: fixed; border: 1px solid #0011ff; background: rgba(0, 17, 255, .08); pointer-events: none; z-index: 10; }
.toast {
    position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); max-width: 90vw;
    background: #222; color: #fff; padding: 9px 14px; border-radius: 8px; z-index: 40;
}
.toast a { color: #9cf; }

@media (max-width: 800px) {
    .top { flex-wrap: wrap; height: auto; padding: 8px 12px; gap: 8px; }
    .view.is-active { flex-direction: column; overflow-y: auto; }
    .side { width: auto; border-right: 0; border-bottom: 1px solid #e6e6e6; padding-bottom: 16px; }
    .sheet { overflow: visible; padding: 12px; }
    .photo { height: 110px; }
}
