/* ── Block Layout Engine ── */
.layout { display: flex; height: calc(100vh - var(--statusbar-h)); width: calc(100vw - var(--sidebar-w)); gap: 1px; background: var(--border); }
.layout-col { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.layout-row { display: flex; flex-direction: column; gap: 1px; min-height: 0; }
.block { background: var(--bg-panel); display: flex; flex-direction: column; min-height: 0; overflow: hidden; position: relative; }
.block.maximized { position: fixed; top: 0; left: 0; width: calc(100vw - var(--sidebar-w)); height: calc(100vh - var(--statusbar-h)); z-index: 100; }
.block.dragging { opacity: 0.5; }

.block-header { height: var(--block-header); min-height: var(--block-header); display: flex; align-items: center; padding: 0 10px; gap: 6px; background: var(--bg-card); border-bottom: 1px solid var(--border); cursor: default; user-select: none; }
.block-icon { font-size: 12px; }
.block-title { font-size: 11px; font-weight: 600; color: var(--text-dim); flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.block-btn { background: none; border: none; color: var(--text-muted); font-size: 12px; cursor: pointer; padding: 2px 4px; border-radius: 3px; line-height: 1; }
.block-btn:hover { color: var(--text); background: var(--bg-hover); }
.block-body { flex: 1; overflow-y: auto; overflow-x: hidden; }
.block-body::-webkit-scrollbar { width: 4px; }
.block-body::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* ── Resize Handles ── */
.resize-handle { background: var(--border); flex-shrink: 0; position: relative; }
.resize-handle-row { height: 4px; cursor: ns-resize; }
.resize-handle-col { width: 4px; cursor: ew-resize; }
.resize-handle:hover { background: var(--accent); }

/* ── Drag & Drop Zones ── */
.drop-zones { position: absolute; top: 0; left: 0; right: 0; bottom: 0; pointer-events: none; z-index: 10; }
.drop-zone { position: absolute; background: var(--accent); opacity: 0; transition: opacity .15s; }
.drop-zone.active { opacity: 0.3; }
.drop-zone-top { top: 0; left: 0; right: 0; height: 50%; }
.drop-zone-bottom { bottom: 0; left: 0; right: 0; height: 50%; }
.drop-zone-left { top: 0; left: 0; bottom: 0; width: 50%; }
.drop-zone-right { top: 0; right: 0; bottom: 0; width: 50%; }
.drop-zone-center { top: 25%; left: 25%; right: 25%; bottom: 25%; }

/* ── Status Bar ── */
.add-bar { position: fixed; bottom: 0; left: 0; right: var(--sidebar-w); height: var(--statusbar-h); background: var(--bg-card); border-top: 1px solid var(--border); display: flex; align-items: center; justify-content: flex-start; padding-left: 12px; gap: 8px; z-index: 50; }
.add-btn { background: var(--bg-hover); border: 1px solid var(--border); color: var(--text-dim); font-size: 11px; padding: 4px 12px; border-radius: 4px; cursor: pointer; display: flex; align-items: center; gap: 4px; }
.add-btn:hover { color: var(--text); border-color: var(--accent); }

/* ── Complications ── */
.complication { display: inline-flex; align-items: center; }
.complication-btn { background: none; border: none; color: var(--text-dim); font-size: 11px; cursor: pointer; padding: 4px 8px; border-radius: 4px; transition: background .12s, color .12s; }
.complication-btn:hover { background: var(--bg-hover); color: var(--text); }
.wall-clock { font-size: 11px; color: var(--accent); font-variant-numeric: tabular-nums; margin-left: auto; }

/* ── Widget Sidebar ── */
.widget-sidebar { position: fixed; right: 0; top: 0; bottom: 0; width: var(--sidebar-w); background: var(--bg-card); border-left: 1px solid var(--border); display: flex; flex-direction: column; gap: 2px; padding: 8px 4px; z-index: 60; transition: width .2s; }
.widget-sidebar:hover { width: 160px; }
.widget-sidebar.docked { width: 160px; }
.widget-btn { background: none; border: none; color: var(--text-dim); cursor: pointer; padding: 8px; border-radius: 6px; display: flex; align-items: center; gap: 8px; white-space: nowrap; transition: background .12s; }
.widget-btn:hover { background: var(--bg-hover); color: var(--text); }
.widget-btn.pinned { color: var(--accent); }
.widget-btn.dragging { opacity: 0.4; }
.widget-btn.drop-target { border-top: 2px solid var(--accent); }
.icon { font-size: 16px; min-width: 20px; text-align: center; }
.label { font-size: 11px; overflow: hidden; width: 0; transition: width .2s, opacity .2s; opacity: 0; }
.widget-sidebar:hover .label, .widget-sidebar.docked .label { width: auto; opacity: 1; }
.sidebar-pin { position: absolute; top: 4px; right: 4px; font-size: 10px; color: var(--text-muted); opacity: 0; transition: opacity .15s, transform .2s; z-index: 1; filter: grayscale(1); transform: rotate(45deg); }
.widget-sidebar:hover .sidebar-pin, .widget-sidebar.docked .sidebar-pin { opacity: 0.5; }
.sidebar-pin:hover { opacity: 1 !important; color: var(--text); }
.widget-sidebar.docked .sidebar-pin { opacity: 0.8; filter: grayscale(1); transform: rotate(0deg); }
.sidebar-divider { height: 1px; background: var(--border); margin: 4px 0; }
.widget-more { position: relative; }
.widget-more-menu { position: absolute; right: 100%; top: 0; background: var(--bg-card); border: 1px solid var(--border); border-radius: 6px; padding: 4px; min-width: 160px; display: none; box-shadow: 0 4px 12px rgba(0,0,0,.3); }
.widget-more:hover .widget-more-menu { display: block; }

/* ── Mobile ── */
@media (max-width: 768px) {
  .layout { flex-direction: column; }
  .add-bar { gap: 4px; flex-wrap: wrap; height: auto; padding: 6px; }
  .add-btn { font-size: 10px; padding: 3px 8px; }
}
@media (max-width: 480px) {
  .block-header { padding: 0 6px; }
  .block-title { font-size: 10px; }
}
