:root {
  color-scheme: dark;
  --bg: #111113;
  --panel: #18181b;
  --panel-soft: #151518;
  --text: #f4f4f5;
  --muted: #a1a1aa;
  --border: rgba(255, 255, 255, 0.1);
  --hover: rgba(255, 255, 255, 0.08);
  --input: #232328;
  --accent: #fafafa;
  --accent-text: #111113;
  --danger: #f87171;
  --grid-size: 72px;
  --grid-col-gap: 10px;
  --grid-row-gap: 14px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.app-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 2rem 1rem;
}

body.dashboard-mode .app-shell {
  display: block;
  padding: 0;
}

.view {
  width: 100%;
  max-width: 440px;
}

body.dashboard-mode .view {
  max-width: none;
}

#view-dashboard {
  width: 100%;
  min-height: 100vh;
}

.hidden {
  display: none !important;
}

.auth-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1.5rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

h1,
h2,
h3 {
  margin: 0 0 0.5rem;
}

.subtitle {
  margin: 0 0 1rem;
  color: var(--muted);
  line-height: 1.4;
}

form {
  display: grid;
  gap: 0.65rem;
}

label {
  font-size: 0.9rem;
  color: var(--muted);
}

input {
  width: 100%;
  border: 1px solid var(--border);
  background: var(--input);
  color: var(--text);
  border-radius: 10px;
  padding: 0.7rem 0.8rem;
  outline: none;
}

input:focus {
  border-color: rgba(255, 255, 255, 0.4);
}

button {
  border: 0;
  border-radius: 10px;
  padding: 0.72rem 0.9rem;
  font-weight: 600;
  cursor: pointer;
  background: var(--accent);
  color: var(--accent-text);
}

button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.error-message {
  margin: 0.25rem 0 0;
  min-height: 1.2rem;
  color: var(--danger);
  font-size: 0.9rem;
}

#qr-container {
  display: grid;
  place-items: center;
  min-height: 210px;
  margin: 0 0 1rem;
  background: #fff;
  border-radius: 12px;
  border: 1px solid #e4e4e7;
  padding: 0.8rem;
}

#qr-container img,
#qr-container svg,
#qr-container canvas {
  max-width: 100%;
  height: auto;
}

.dashboard-shell {
  width: 100%;
  min-height: 100vh;
  background: var(--panel-soft);
  border: 0;
  border-radius: 0;
  overflow: hidden;
}

.toolbox-horizontal-ribbon {
  width: 100%;
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 8px 0 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}

.dashboard-navigation {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.dashboard-ribbon-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.dashboard-tabs {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
}

.dashboard-tab,
.dashboard-edit-button,
.dashboard-new-button,
.logout-subtle,
.toolbox-subtab-trigger,
.toolbox-subtab-add-btn,
.toolbox-subtab-delete-btn,
.dashboard-grid-add-cell {
  border: none;
  outline: none;
  box-shadow: none;
  background: transparent;
  color: rgba(255, 255, 255, 0.72);
}

.dashboard-tab,
.dashboard-edit-button {
  min-height: 30px;
  border-radius: 8px;
  padding: 4px 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.dashboard-edit-button {
  width: 30px;
  padding: 0;
  font-size: 16px;
  line-height: 1;
}

.dashboard-tab:hover,
.dashboard-edit-button:hover,
.dashboard-new-button:hover,
.logout-subtle:hover {
  background: var(--hover);
  color: #fff;
}

.dashboard-tab.is-active {
  background: var(--hover);
  color: #fff;
}

.dashboard-tab .dashboard-tab-icon,
.dashboard-tab img {
  width: 18px;
  height: 18px;
  margin-right: 6px;
  flex-shrink: 0;
}

.dashboard-tab img {
  object-fit: cover;
  border-radius: 4px;
}

.dashboard-tab-label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.toolbox-ribbon-divider {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 28px;
  padding: 0 6px;
}

.toolbox-ribbon-divider-line {
  width: 1.5px;
  height: 22px;
  background: rgba(255, 255, 255, 0.35);
  border-radius: 1px;
}

.toolbox-ribbon-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.dashboard-new-button {
  font-size: 12px;
  padding: 5px 10px;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.logout-subtle {
  padding: 5px 10px;
  font-size: 12px;
  opacity: 0.8;
}

.toolbox-tab-nav-menu {
  width: 100%;
  border-top: 1px solid rgba(255, 255, 255, 0.04);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.toolbox-tab-nav-items {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 16px;
  min-height: 32px;
  overflow-x: auto;
}

.toolbox-subtab-item {
  display: inline-flex;
  align-items: center;
}

.toolbox-subtab-trigger {
  text-transform: uppercase;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
  padding: 4px 10px;
  border-radius: 6px;
}

.toolbox-subtab-item.is-active .toolbox-subtab-trigger {
  background: var(--hover);
  color: #fff;
}

.toolbox-subtab-add-btn {
  width: 20px;
  height: 20px;
  border-radius: 6px;
  font-size: 14px;
  line-height: 1;
}

.toolbox-subtab-add-btn:hover,
.toolbox-subtab-delete-btn:hover {
  background: var(--hover);
  color: #fff;
}

.toolbox-subtab-delete-btn {
  opacity: 0;
  margin-left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 4px;
  font-size: 13px;
  line-height: 1;
  padding: 0;
}

.toolbox-subtab-item:hover .toolbox-subtab-delete-btn {
  opacity: 0.9;
}

.toolbox-subtab-inline-input {
  width: 120px;
  height: 24px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 4px 8px;
  border-radius: 6px;
}

.toolbox-app-dropdown-host:empty {
  display: none;
}

.app-dropdown-toggle {
  width: 100%;
  border-radius: 0;
  border: 0;
  border-bottom: 1px solid var(--border);
  background: transparent;
  color: rgba(255, 255, 255, 0.72);
  text-align: left;
  padding: 8px 16px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.app-dropdown-toggle:hover {
  background: var(--hover);
  color: #fff;
}

.toolbox-app-dropdown {
  width: 100%;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding: 20px;
  overflow-x: auto;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(var(--dashboard-grid-cols, 10), var(--grid-size));
  grid-template-rows: repeat(var(--dashboard-grid-rows, 4), var(--grid-size));
  column-gap: var(--grid-col-gap);
  row-gap: var(--grid-row-gap);
  align-items: start;
  justify-content: start;
  padding: 18px;
}

.dashboard-grid-cell {
  width: var(--grid-size);
  height: var(--grid-size);
  border-radius: 12px;
  position: relative;
}

.dashboard-grid-cell.is-drop-target {
  background: rgba(255, 255, 255, 0.08);
}

.dashboard-grid-add-cell {
  width: 100%;
  height: 100%;
  border-radius: 12px;
  font-size: 18px;
  cursor: pointer;
  opacity: 0;
}

.dashboard-grid-cell:not(.is-occupied):hover .dashboard-grid-add-cell {
  opacity: 1;
  background: rgba(255, 255, 255, 0.04);
}

.toolbox-container {
  width: 100%;
  height: 100%;
  position: relative;
  pointer-events: none;
  z-index: 1;
}

.toolbox-container-frame {
  position: absolute;
  inset: -2px -3px -3px -3px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.015);
  pointer-events: none;
}

.toolbox-container-frame.is-editing {
  pointer-events: auto;
}

.toolbox-container-title {
  position: absolute;
  top: -6px;
  left: 10px;
  width: max-content;
  max-width: calc(100% - 28px);
  background: var(--bg);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 8.5px;
  line-height: 1;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.85);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: auto;
}

.toolbox-container-title-input {
  position: absolute;
  top: -6px;
  left: 10px;
  height: 18px;
  font-size: 8.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 1px 6px;
  border-radius: 4px;
  z-index: 4;
}

.toolbox-container-delete-btn {
  position: absolute;
  top: 4px;
  right: 6px;
  width: 16px;
  height: 16px;
  border: none;
  background: transparent;
  color: rgba(255, 255, 255, 0.65);
  border-radius: 4px;
  cursor: pointer;
  z-index: 4;
}

.toolbox-container-delete-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.toolbox-container-resize-handle {
  position: absolute;
  right: 4px;
  bottom: 4px;
  width: 12px;
  height: 12px;
  border-radius: 3px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  background: rgba(255, 255, 255, 0.08);
  cursor: se-resize;
  z-index: 3;
}

.dashboard-card {
  width: var(--grid-size);
  height: var(--grid-size);
  padding: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  background: var(--panel);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: transform 120ms ease, background-color 120ms ease;
  z-index: 2;
}

.dashboard-card:hover {
  background: rgba(255, 255, 255, 0.08);
}

.dashboard-card.is-dragging {
  opacity: 0.65;
}

.dashboard-card.is-in-container {
  transform: translateY(2px) scale(0.84);
  transform-origin: center;
}

.dashboard-card.is-in-container:hover {
  transform: translateY(1px) scale(0.87);
}

.dashboard-card img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 8px;
}

.page-content {
  padding: 16px;
}

.page-content-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: grid;
  place-items: center;
  z-index: 40;
  padding: 1rem;
}

.modal-card {
  width: min(480px, 100%);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1rem;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

button.ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}

button.danger {
  color: var(--danger);
}
