@font-face { font-family: 'DM Mono'; font-style: normal; font-weight: 400; font-display: swap; src: url('assets/dm-mono-400.woff2') format('woff2'); }
@font-face { font-family: 'DM Mono'; font-style: normal; font-weight: 500; font-display: swap; src: url('assets/dm-mono-500.woff2') format('woff2'); }
@font-face { font-family: Manrope; font-style: normal; font-weight: 400 700; font-display: swap; src: url('assets/manrope-400-700.woff2') format('woff2'); }

:root {
    --ink: #17201e;
    --muted: #697570;
    --paper: #f4f6f1;
    --surface: #ffffff;
    --line: #dce2dc;
    --forest: #163f35;
    --forest-hover: #0f3028;
    --mint: #bde8d6;
    --signal: #f4c85b;
    --danger: #bd3f36;
    --shadow: 0 18px 60px rgba(25, 42, 37, .12);
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; color: var(--ink); background: var(--paper); font-family: Manrope, sans-serif; letter-spacing: 0; caret-color: transparent; }
button, input { font: inherit; letter-spacing: 0; }
input, textarea, [contenteditable="true"] { caret-color: var(--ink); }
button { cursor: pointer; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.texture { position: fixed; inset: 0; pointer-events: none; opacity: .38; background-image: radial-gradient(#91a19a 0.6px, transparent 0.6px); background-size: 18px 18px; mask-image: linear-gradient(to bottom, black, transparent 80%); }

.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; }
.brand-mark { display: grid; place-items: center; width: 34px; height: 34px; background: var(--signal); color: #342c12; font: 500 18px 'DM Mono', monospace; }
.eyebrow { margin: 0 0 8px; color: #527168; font: 500 12px 'DM Mono', monospace; text-transform: uppercase; }

.connection-view { position: relative; z-index: 1; display: grid; grid-template-columns: minmax(420px, 620px) minmax(360px, 1fr); min-height: 100vh; }
.connection-panel { display: flex; flex-direction: column; padding: clamp(28px, 6vw, 80px); background: rgba(255,255,255,.82); backdrop-filter: blur(16px); }
.connection-header { display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.connection-header-actions { display: flex; align-items: center; gap: 20px; }
.connection-copy { margin: auto 0 32px; max-width: 510px; }
.connection-copy h1 { margin: 0 0 16px; font-size: clamp(42px, 6vw, 72px); line-height: .98; font-weight: 600; }
.connection-copy > p:last-child { max-width: 470px; margin: 0; color: var(--muted); font-size: 17px; line-height: 1.7; }
.connect-form { display: grid; gap: 10px; max-width: 510px; margin-top: clamp(36px, 7vh, 72px); }
.connect-controls { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 9px; }
.connect-controls .primary-button { min-width: 132px; }
.custom-connection-button { width: max-content; padding: 0; }
label { color: #44504c; font-size: 13px; font-weight: 600; }
input { width: 100%; height: 46px; padding: 0 14px; color: var(--ink); background: var(--surface); border: 1px solid #cbd3ce; border-radius: 5px; outline: none; }
input:focus { border-color: var(--forest); box-shadow: 0 0 0 3px rgba(22,63,53,.12); }
.primary-button, .secondary-button { min-height: 44px; display: inline-flex; align-items: center; justify-content: center; gap: 9px; padding: 0 18px; border-radius: 5px; border: 1px solid transparent; font-weight: 700; }
.primary-button { color: white; background: var(--forest); }
.primary-button:hover { background: var(--forest-hover); }
.primary-button:disabled { opacity: .55; cursor: wait; }
.secondary-button { color: var(--ink); background: white; border-color: var(--line); }
.secondary-button:hover { border-color: #9eaaa4; }
.text-button { min-height: 38px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; color: var(--forest); background: transparent; border: 0; font-weight: 700; }
.text-button:hover { text-decoration: underline; }
.source-link { text-decoration: none; }
.text-button svg { width: 16px; }
.primary-button svg, .secondary-button svg { width: 17px; }
.privacy-note { display: flex; align-items: center; gap: 8px; margin: 26px 0 0; color: var(--muted); font-size: 12px; }
.privacy-note svg { width: 16px; }
.connection-art { position: relative; overflow: hidden; display: grid; place-items: center; min-height: 100vh; background: var(--forest); color: white; }
.art-grid { position: absolute; inset: 0; opacity: .15; background-image: linear-gradient(rgba(255,255,255,.2) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.2) 1px, transparent 1px); background-size: 72px 72px; }
.storage-stack { z-index: 1; width: min(52%, 390px); display: grid; gap: 18px; transform: perspective(800px) rotateY(-12deg) rotateX(4deg); }
.storage-stack span { height: 86px; border: 1px solid rgba(255,255,255,.28); background: linear-gradient(100deg, rgba(189,232,214,.22), rgba(255,255,255,.04)); box-shadow: 18px 18px 0 rgba(5,25,20,.22); }
.storage-stack span::after { content: ''; display: block; width: 12px; height: 12px; margin: 36px 22px 0 auto; background: var(--signal); border-radius: 50%; box-shadow: -28px 0 0 var(--mint); }
.connection-art p { position: absolute; bottom: 42px; left: 42px; margin: 0; color: #d7e5df; }

.browser-view { position: relative; z-index: 1; min-height: 100vh; }
.app-header { height: 70px; display: flex; justify-content: space-between; align-items: center; padding: 0 clamp(20px, 5vw, 72px); background: var(--surface); border-bottom: 1px solid var(--line); }
.header-actions { display: flex; align-items: center; gap: 24px; }
.help-button { padding: 0 4px; }
.connection-status { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; }
.connection-status span { width: 8px; height: 8px; border-radius: 50%; background: #36a66f; box-shadow: 0 0 0 4px #daf1e4; }
.bucket-heading { display: flex; align-items: end; justify-content: space-between; gap: 24px; padding: 46px clamp(20px, 5vw, 72px) 28px; }
.bucket-heading h1 { margin: 0; max-width: 70vw; overflow-wrap: anywhere; font-size: clamp(28px, 4vw, 44px); font-weight: 600; }
.workspace-actions { display: flex; align-items: center; gap: 18px; }
.danger-toggle, .endpoint-consent { display: flex; align-items: center; gap: 9px; color: var(--muted); cursor: pointer; }
.danger-toggle input, .endpoint-consent input { flex: 0 0 auto; width: 16px; height: 16px; accent-color: var(--danger); }
.danger-toggle:has(input:checked) { color: var(--danger); }
.endpoint-consent { padding: 12px; background: #fff8df; border-left: 3px solid var(--signal); font-size: 12px; line-height: 1.45; }
.toolbar { display: grid; grid-template-columns: minmax(220px, 1fr) minmax(180px, 320px) 44px; gap: 10px; padding: 0 clamp(20px, 5vw, 72px) 22px; }
.search-control, .prefix-control { position: relative; display: flex; align-items: center; }
.search-control svg { position: absolute; left: 14px; width: 18px; color: var(--muted); }
.search-control input { padding-left: 43px; }
.prefix-control span { position: absolute; left: 13px; color: var(--muted); font: 500 11px 'DM Mono', monospace; text-transform: uppercase; }
.prefix-control input { padding-left: 67px; font-family: 'DM Mono', monospace; font-size: 13px; }
.icon-button { width: 38px; height: 38px; display: inline-grid; place-items: center; padding: 0; color: #53605b; background: transparent; border: 1px solid transparent; border-radius: 4px; }
.icon-button:hover { color: var(--ink); background: #edf1ed; }
.icon-button svg { width: 17px; height: 17px; }
.refresh-button { width: 44px; height: 46px; background: white; border-color: #cbd3ce; }
.is-spinning svg { animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.object-browser { margin: 0 clamp(20px, 5vw, 72px) 60px; background: var(--surface); border: 1px solid var(--line); border-radius: 6px; box-shadow: 0 8px 30px rgba(25,42,37,.05); }
.browser-meta { height: 48px; display: flex; align-items: center; justify-content: space-between; padding: 0 18px; color: var(--muted); border-bottom: 1px solid var(--line); font-size: 12px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; table-layout: fixed; }
th { padding: 13px 18px; color: var(--muted); background: #fafbf9; border-bottom: 1px solid var(--line); text-align: left; font: 500 11px 'DM Mono', monospace; text-transform: uppercase; }
th:nth-child(1) { width: 52%; } th:nth-child(2) { width: 13%; } th:nth-child(3) { width: 23%; } th:nth-child(4) { width: 132px; }
td { height: 64px; padding: 8px 18px; color: #59645f; border-bottom: 1px solid #edf0ed; font-size: 13px; }
.object-cell { display: flex; align-items: center; gap: 12px; min-width: 0; }
.file-icon { flex: 0 0 32px; height: 32px; display: grid; place-items: center; color: var(--forest); background: #e4f1eb; }
.file-icon svg { width: 16px; }
.object-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; color: var(--ink); background: none; border: 0; text-align: left; font-family: 'DM Mono', monospace; font-size: 13px; white-space: nowrap; }
.object-name:hover { color: #176b55; text-decoration: underline; }
.row-actions { display: flex; align-items: center; justify-content: flex-end; padding-top: 13px; }
.icon-button.danger:hover { color: var(--danger); background: #fae9e7; }
.empty-state { min-height: 320px; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 42px; text-align: center; }
.empty-visual { width: 76px; height: 76px; display: grid; place-items: center; margin-bottom: 22px; color: var(--forest); background: var(--mint); border: 10px solid #eaf6f1; border-radius: 50%; }
.empty-visual svg { width: 25px; }
.empty-state h2 { margin: 0 0 8px; font-size: 20px; }
.empty-state p { margin: 0 0 22px; color: var(--muted); }

.help-view { position: relative; z-index: 1; min-height: 100vh; background: var(--paper); }
.help-content { width: min(960px, calc(100% - 40px)); margin: 0 auto; padding: clamp(52px, 8vw, 96px) 0 90px; }
.help-intro { max-width: 760px; margin-bottom: 70px; }
.help-intro h1 { margin: 0 0 22px; font-size: clamp(38px, 6vw, 68px); line-height: 1.04; font-weight: 600; }
.help-intro > p:last-child { margin: 0; color: var(--muted); font-size: 18px; line-height: 1.75; }
.help-download-row { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 26px; }
.help-download { width: max-content; text-decoration: none; }
.help-section { display: grid; grid-template-columns: 70px minmax(0, 1fr); gap: 26px; padding: 38px 0; border-top: 1px solid var(--line); }
.help-section > div { min-width: 0; }
.help-step { color: #527168; font: 500 13px 'DM Mono', monospace; }
.help-section h2 { margin: -6px 0 12px; font-size: 24px; }
.help-section p { max-width: 740px; margin: 0; color: var(--muted); line-height: 1.7; }
.help-section pre { max-width: 100%; margin: 22px 0 0; padding: 20px; overflow-x: auto; color: #dce9e4; background: #172520; border-radius: 5px; font: 12px/1.65 'DM Mono', monospace; }
.help-callout { display: grid; grid-template-columns: 24px minmax(0, 1fr); gap: 13px; margin-top: 22px; padding: 18px; background: #fff8df; border-left: 3px solid var(--signal); }
.help-callout svg { width: 20px; color: #7a611b; }
.help-callout p { color: #5f542f; font-size: 14px; }

dialog { max-width: calc(100vw - 24px); max-height: calc(100svh - 24px); padding: 0; overflow: auto; color: var(--ink); background: var(--surface); border: 0; border-radius: 6px; box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(15,31,27,.58); backdrop-filter: blur(3px); }
.dialog-body { width: min(480px, calc(100vw - 40px)); display: grid; gap: 11px; padding: 26px; }
.dialog-header { display: flex; align-items: start; justify-content: space-between; gap: 20px; margin-bottom: 8px; }
.dialog-header h2 { margin: 0; overflow-wrap: anywhere; font-size: 23px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 16px; }
.custom-fields { display: grid; grid-template-columns: .8fr 1.2fr; gap: 12px; }
.custom-fields > * { min-width: 0; }
.custom-fields > div { display: grid; gap: 7px; }
.custom-fields .wide-field { grid-column: 1 / -1; }
.generated-key { display: grid; gap: 7px; margin-top: 8px; }
.generated-key-ready { display: flex; align-items: flex-start; gap: 10px; margin: 0 0 6px; color: var(--muted); font-size: 12px; line-height: 1.5; }
.generated-key-ready svg { flex: 0 0 auto; width: 18px; color: var(--forest); }
.generated-key .secondary-button { width: max-content; }
.file-input { height: auto; padding: 7px; color: var(--muted); background: #f8faf8; cursor: pointer; }
.file-input::file-selector-button { min-height: 34px; margin-right: 12px; padding: 0 14px; color: white; background: var(--forest); border: 0; border-radius: 4px; font: 700 13px Manrope, sans-serif; cursor: pointer; }
.file-input::file-selector-button:hover { background: var(--forest-hover); }
.optional { margin-left: 6px; color: var(--muted); font-size: 11px; font-weight: 500; }
.field-note { margin: 0; color: var(--muted); font-size: 12px; }
.overall-progress { display: grid; gap: 7px; margin-top: 8px; }
.overall-progress > div { display: flex; justify-content: space-between; color: var(--muted); font-size: 12px; }
progress { width: 100%; height: 8px; overflow: hidden; border: 0; border-radius: 0; background: #e7ece8; }
progress::-webkit-progress-bar { background: #e7ece8; }
progress::-webkit-progress-value { background: var(--forest); }
progress::-moz-progress-bar { background: var(--forest); }
.upload-queue { max-height: 230px; display: grid; gap: 10px; overflow-y: auto; padding: 2px 4px 2px 0; }
.upload-item { display: grid; gap: 6px; }
.upload-item-meta { display: flex; justify-content: space-between; gap: 18px; color: var(--muted); font-size: 12px; }
.upload-item-meta span:first-child { min-width: 0; overflow: hidden; color: var(--ink); text-overflow: ellipsis; white-space: nowrap; }
.upload-item progress { height: 4px; }
.preview-dialog .dialog-body { width: min(760px, calc(100vw - 40px)); }
#previewContent { min-height: 220px; max-height: 60vh; margin: 0; padding: 18px; overflow: auto; color: #dce9e4; background: #172520; border-radius: 4px; font: 13px/1.65 'DM Mono', monospace; white-space: pre-wrap; overflow-wrap: anywhere; }
.drop-overlay { position: fixed; z-index: 20; inset: 16px; display: grid; place-items: center; color: white; background: rgba(16, 57, 47, .94); border: 2px dashed var(--mint); border-radius: 6px; opacity: 0; transform: scale(.99); pointer-events: none; transition: opacity .15s, transform .15s; }
.drop-overlay.visible { opacity: 1; transform: scale(1); }
.drop-overlay > div { display: grid; justify-items: center; gap: 10px; text-align: center; }
.drop-overlay svg { width: 44px; height: 44px; color: var(--signal); }
.drop-overlay strong { font-size: clamp(24px, 5vw, 42px); }
.drop-overlay span { color: #d2e6de; }
.toast { position: fixed; z-index: 10; right: 24px; bottom: 24px; max-width: min(420px, calc(100vw - 48px)); padding: 13px 17px; color: white; background: var(--forest); border-left: 4px solid var(--mint); border-radius: 4px; box-shadow: var(--shadow); opacity: 0; transform: translateY(12px); pointer-events: none; transition: opacity .2s, transform .2s; }
.toast.visible { opacity: 1; transform: translateY(0); }
.toast[data-type='error'] { background: #6b2520; border-left-color: #f19b92; }

@media (max-width: 800px) {
    .connection-view { grid-template-columns: 1fr; }
    .connection-panel { min-height: 100vh; }
    .connection-art { display: none; }
    .bucket-heading { align-items: stretch; flex-direction: column; }
    .workspace-actions { justify-content: space-between; }
    .bucket-heading h1 { max-width: 100%; }
    .toolbar { grid-template-columns: 1fr 44px; }
    .search-control { grid-column: 1 / -1; }
    th:nth-child(2), td:nth-child(2), th:nth-child(3), td:nth-child(3) { display: none; }
    th:nth-child(1) { width: auto; } th:nth-child(4) { width: 124px; }
    thead tr, tbody tr { display: grid; grid-template-columns: minmax(0, 1fr) 124px; }
    tbody tr { border-bottom: 1px solid #edf0ed; }
    td { border-bottom: 0; }
    .row-actions { height: 64px; padding-top: 0; }
}

@media (max-width: 480px) {
    .connection-view { min-height: 100svh; }
    .connection-panel { min-height: 0; padding: 24px 20px 32px; backdrop-filter: none; }
    .connection-header, .app-header { position: static; }
    .texture { display: none; }
    .connection-header-actions { gap: 10px; }
    .connect-form { margin-top: 34px; }
    .connect-controls { grid-template-columns: 1fr; }
    .connection-copy { margin: 34px 0 0; padding-top: 0; }
    .privacy-note { margin-top: 24px; }
    .custom-fields { grid-template-columns: 1fr; }
    .custom-fields .wide-field { grid-column: auto; }
    .app-header { height: 62px; }
    .header-actions { gap: 12px; }
    .connection-status { font-size: 0; }
    .help-content { width: min(100% - 32px, 960px); padding-top: 48px; }
    .help-intro { margin-bottom: 50px; }
    .help-section { grid-template-columns: 1fr; gap: 14px; padding: 30px 0; }
    .help-section h2 { margin-top: 0; font-size: 21px; }
    .help-section pre { margin-left: -4px; margin-right: -4px; padding: 16px; font-size: 11px; }
    .bucket-heading { padding-top: 30px; }
    .browser-meta span:last-child { display: none; }
    td, th { padding-left: 12px; padding-right: 8px; }
    .row-actions .icon-button { width: 34px; }
    .file-icon { display: none; }
}

@media (max-width: 480px) and (max-height: 620px) {
    .connection-panel { padding-top: 18px; padding-bottom: 22px; }
    .connect-form { margin-top: 24px; }
    .connection-copy { margin-top: 26px; }
    .connection-copy h1 { margin-bottom: 12px; font-size: 38px; line-height: 1; }
    .connection-copy > p:last-child { font-size: 15px; line-height: 1.55; }
    .privacy-note { margin-top: 18px; }
}

@media (max-width: 360px) {
    .connection-header-actions { gap: 4px; }
    .connection-header-actions .text-button { width: 38px; padding: 0; }
    .connection-header-actions .text-button span { display: none; }
}
