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

body {
  background: #0a0a1a;
  color: #eee;
  font-family: 'Segoe UI', Arial, sans-serif;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.header {
  display: flex;
  align-items: center;
  padding: 10px 20px;
  background: #111;
  border-bottom: 1px solid #222;
  gap: 12px;
  flex-wrap: wrap;
}

.header h1 {
  font-size: 16px;
  color: #e94560;
  font-weight: 600;
  margin-right: auto;
}

/* --- Layout Picker --- */
.layout-picker {
  display: flex;
  gap: 4px;
}

.layout-btn {
  background: #222;
  border: 1px solid #333;
  border-radius: 4px;
  padding: 5px;
  cursor: pointer;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, border-color 0.15s;
}

.layout-btn svg {
  width: 18px;
  height: 18px;
  fill: #666;
  transition: fill 0.15s;
}

.layout-btn:hover {
  background: #2a2a3e;
  border-color: #555;
}

.layout-btn:hover svg {
  fill: #aaa;
}

.layout-btn.active {
  background: #1a1a3e;
  border-color: #e94560;
}

.layout-btn.active svg {
  fill: #e94560;
}

.clear-btn {
  background: #333;
  color: #ccc;
  border: none;
  padding: 6px 14px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
}

.clear-btn:hover {
  background: #e94560;
  color: #fff;
}

/* --- Grid (default: 2x2) --- */
.grid {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  min-height: 0;
}

/* --- Layout: Solo --- */
.grid.layout-solo {
  grid-template-columns: 1fr;
  grid-template-rows: 1fr;
}
.grid.layout-solo .cell:nth-child(n+2) {
  display: none;
}

/* --- Layout: Side by Side --- */
.grid.layout-side-by-side {
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr;
}
.grid.layout-side-by-side .cell:nth-child(n+3) {
  display: none;
}

/* --- Layout: Stacked --- */
.grid.layout-stacked {
  grid-template-columns: 1fr;
  grid-template-rows: 1fr 1fr;
}
.grid.layout-stacked .cell:nth-child(n+3) {
  display: none;
}

/* --- Layout: Grid (2x2, default) --- */
.grid.layout-grid {
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
}

/* --- Layout: Big Left (1 big + 2 small right) --- */
.grid.layout-big-left {
  grid-template-columns: 2fr 1fr;
  grid-template-rows: 1fr 1fr;
}
.grid.layout-big-left .cell:nth-child(1) {
  grid-row: 1 / 3;
}
.grid.layout-big-left .cell:nth-child(n+4) {
  display: none;
}

/* --- Layout: Big Top (1 big + 3 small bottom) --- */
.grid.layout-big-top {
  grid-template-columns: 1fr 1fr 1fr;
  grid-template-rows: 2fr 1fr;
}
.grid.layout-big-top .cell:nth-child(1) {
  grid-column: 1 / 4;
}

/* --- Layout: Big Right (2 small left + 1 big) --- */
.grid.layout-big-right {
  grid-template-columns: 1fr 2fr;
  grid-template-rows: 1fr 1fr;
}
.grid.layout-big-right .cell:nth-child(1) {
  grid-column: 1;
  grid-row: 1;
}
.grid.layout-big-right .cell:nth-child(2) {
  grid-column: 1;
  grid-row: 2;
}
.grid.layout-big-right .cell:nth-child(3) {
  grid-column: 2;
  grid-row: 1 / 3;
}
.grid.layout-big-right .cell:nth-child(n+4) {
  display: none;
}

/* --- Layout: Triple --- */
.grid.layout-triple {
  grid-template-columns: 1fr 1fr 1fr;
  grid-template-rows: 1fr;
}
.grid.layout-triple .cell:nth-child(n+4) {
  display: none;
}

/* --- Cell styles --- */
.cell {
  background: #111;
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid #222;
  transition: border-color 0.15s;
}

.cell.drag-over {
  border-color: #e94560;
  box-shadow: 0 0 12px rgba(233, 69, 96, 0.3);
}

.cell.dragging {
  opacity: 0.5;
}

.cell-header {
  display: flex;
  align-items: center;
  padding: 4px 10px;
  background: #1a1a2e;
  border-bottom: 1px solid #222;
  gap: 8px;
  min-height: 30px;
}

.cell-label {
  font-size: 11px;
  font-weight: bold;
  color: #e94560;
  white-space: nowrap;
  cursor: grab;
}

.cell-label:active {
  cursor: grabbing;
}

.cell-title {
  font-size: 11px;
  color: #888;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

.cell-refresh,
.cell-close {
  background: none;
  border: none;
  color: #555;
  font-size: 16px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}

.cell-refresh:hover {
  color: #53cf6e;
}

.cell-close:hover {
  color: #e94560;
}

.cell-content {
  flex: 1;
  position: relative;
  min-height: 0;
}

.cell-content iframe {
  width: 100%;
  height: 100%;
  border: none;
  position: absolute;
  top: 0;
  left: 0;
}

.empty-state {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: #444;
  font-size: 13px;
  text-align: center;
  padding: 20px;
}
