/* KIK.OS Platform — system UI (not SOMA dashboard) */

:root {
  --font: "Inter", system-ui, -apple-system, sans-serif;
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-xl: 24px;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 24px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.12);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --chrome-blur: 20px;

  --bg: #f5f5f7;
  --bg-elevated: #ffffff;
  --text: #1d1d1f;
  --text-secondary: #6e6e73;
  --text-tertiary: #86868b;
  --border: rgba(0, 0, 0, 0.08);
  --chrome-bg: rgba(255, 255, 255, 0.72);
  --chrome-border: rgba(0, 0, 0, 0.06);
  --accent: #0071e3;
  --accent-soft: rgba(0, 113, 227, 0.12);
  --danger: #ff3b30;
  --tile-bg: #ffffff;
  --tile-hover: #fafafa;
  --kbd-bg: rgba(0, 0, 0, 0.06);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #000000;
    --bg-elevated: #1c1c1e;
    --text: #f5f5f7;
    --text-secondary: #a1a1a6;
    --text-tertiary: #6e6e73;
    --border: rgba(255, 255, 255, 0.1);
    --chrome-bg: rgba(28, 28, 30, 0.78);
    --chrome-border: rgba(255, 255, 255, 0.08);
    --accent: #0a84ff;
    --accent-soft: rgba(10, 132, 255, 0.18);
    --tile-bg: #1c1c1e;
    --tile-hover: #2c2c2e;
    --kbd-bg: rgba(255, 255, 255, 0.1);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 24px rgba(0, 0, 0, 0.4);
  }
}

:root[data-theme="light"] {
  color-scheme: light;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #000000;
  --bg-elevated: #1c1c1e;
  --text: #f5f5f7;
  --text-secondary: #a1a1a6;
  --text-tertiary: #6e6e73;
  --border: rgba(255, 255, 255, 0.1);
  --chrome-bg: rgba(28, 28, 30, 0.78);
  --chrome-border: rgba(255, 255, 255, 0.08);
  --accent: #0a84ff;
  --accent-soft: rgba(10, 132, 255, 0.18);
  --tile-bg: #1c1c1e;
  --tile-hover: #2c2c2e;
  --kbd-bg: rgba(255, 255, 255, 0.1);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 24px rgba(0, 0, 0, 0.4);
}

:root[data-theme="light"] {
  --bg: #f5f5f7;
  --bg-elevated: #ffffff;
  --text: #1d1d1f;
  --text-secondary: #6e6e73;
  --text-tertiary: #86868b;
  --border: rgba(0, 0, 0, 0.08);
  --chrome-bg: rgba(255, 255, 255, 0.72);
  --chrome-border: rgba(0, 0, 0, 0.06);
  --accent: #0071e3;
  --accent-soft: rgba(0, 113, 227, 0.12);
  --tile-bg: #ffffff;
  --tile-hover: #fafafa;
  --kbd-bg: rgba(0, 0, 0, 0.06);
}

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

html {
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}

button,
input,
select {
  font: inherit;
  color: inherit;
}

.platform {
  max-width: 960px;
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding-bottom: env(safe-area-inset-bottom, 0);
}

/* ── Chrome (Liquid Glass inspired) ── */

.chrome {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 20px;
  background: var(--chrome-bg);
  border-bottom: 1px solid var(--chrome-border);
  backdrop-filter: blur(var(--chrome-blur)) saturate(1.4);
  -webkit-backdrop-filter: blur(var(--chrome-blur)) saturate(1.4);
}

.chrome__brand {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.chrome__logo {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.chrome__tag {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.chrome__search {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  cursor: pointer;
  transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease);
  min-width: 0;
}

.chrome__search:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-sm);
}

.chrome__search-icon {
  color: var(--text-tertiary);
  font-size: 16px;
}

.chrome__search-text {
  font-size: 14px;
  color: var(--text-secondary);
}

.chrome__kbd {
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 6px;
  background: var(--kbd-bg);
  color: var(--text-tertiary);
  font-family: inherit;
}

@media (max-width: 520px) {
  .chrome__search-text,
  .chrome__kbd {
    display: none;
  }
  .chrome__search {
    padding: 10px 12px;
  }
}

/* ── Tabs ── */

.tabs {
  display: flex;
  gap: 4px;
  padding: 8px 16px;
  position: sticky;
  top: 57px;
  z-index: 19;
  background: var(--chrome-bg);
  border-bottom: 1px solid var(--chrome-border);
  backdrop-filter: blur(var(--chrome-blur)) saturate(1.4);
  -webkit-backdrop-filter: blur(var(--chrome-blur)) saturate(1.4);
}

.tabs__btn {
  flex: 1;
  padding: 10px 12px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.tabs__btn:hover {
  background: var(--accent-soft);
  color: var(--text);
}

.tabs__btn.is-active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

/* ── Main panels ── */

.main {
  flex: 1;
  padding: 20px 16px 32px;
}

.panel {
  display: none;
  animation: fadeIn 0.2s var(--ease);
}

.panel.is-active {
  display: block;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.panel-title {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 20px;
}

.section-label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-tertiary);
  margin: 24px 0 12px;
}

.section-label:first-child {
  margin-top: 0;
}

/* ── Home hero ── */

.home-hero h1 {
  font-size: clamp(28px, 5vw, 34px);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.15;
}

.home-hero__date {
  margin-top: 6px;
  font-size: 15px;
  color: var(--text-secondary);
  text-transform: capitalize;
}

/* ── Bento ── */

.bento {
  display: grid;
  gap: 12px;
}

.bento--quick {
  grid-template-columns: repeat(2, 1fr);
}

.bento--games {
  grid-template-columns: repeat(3, 1fr);
}

.bento__span-2 {
  grid-column: span 2;
}

body[data-density="compact"] .bento {
  gap: 8px;
}

@media (max-width: 640px) {
  .bento--quick {
    grid-template-columns: 1fr;
  }
  .bento__span-2 {
    grid-column: span 1;
  }
  .bento--games {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ── App tiles ── */

.app-tile {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 12px;
  padding: 16px;
  border-radius: var(--radius-lg);
  background: var(--tile-bg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  text-decoration: none;
  color: inherit;
  transition: transform 0.15s var(--ease), box-shadow 0.15s var(--ease), border-color 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.app-tile:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: transparent;
  background: var(--tile-hover);
}

.app-tile:active {
  transform: scale(0.98);
}

.app-tile--hero {
  flex-direction: row;
  align-items: center;
  padding: 20px;
  min-height: 100px;
}

.app-tile--hero .app-tile__meta {
  flex: 1;
}

.app-tile--hero .app-tile__title {
  font-size: 20px;
}

.app-tile--continue {
  flex-direction: row;
  align-items: center;
  width: 100%;
}

.app-tile--chip {
  flex-direction: row;
  align-items: center;
  padding: 10px 14px;
  border-radius: 999px;
  gap: 10px;
}

.app-tile--chip .app-tile__subtitle {
  display: none;
}

.app-tile--row {
  flex-direction: row;
  align-items: center;
  width: 100%;
  padding: 12px 14px;
  border-radius: var(--radius-md);
}

.app-tile--row .app-tile__meta {
  flex: 1;
}

.app-tile__title {
  display: block;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.app-tile__subtitle {
  display: block;
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.icon-wrap {
  flex-shrink: 0;
  border-radius: 22%;
  overflow: hidden;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.2) inset,
    0 2px 4px rgba(0, 0, 0, 0.08),
    0 12px 28px rgba(0, 0, 0, 0.14);
  background: #111;
}

.app-icon-img {
  display: block;
  width: 64px;
  height: 64px;
  object-fit: cover;
  image-rendering: auto;
}

.icon-wrap--hero .app-icon-img,
.icon-wrap--hero {
  width: 72px;
  height: 72px;
}

.icon-wrap--md .app-icon-img,
.icon-wrap--md {
  width: 64px;
  height: 64px;
}

.icon-wrap--sm .app-icon-img,
.icon-wrap--sm {
  width: 48px;
  height: 48px;
}

.icon-wrap--chip .app-icon-img,
.icon-wrap--chip {
  width: 40px;
  height: 40px;
}

.icon-wrap--cabra .app-icon-img {
  image-rendering: pixelated;
}

.recent-chips,
.continue-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

/* ── Apps list ── */

.apps-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.apps-toolbar .panel-title {
  margin-bottom: 0;
}

.app-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.edit-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: var(--tile-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.edit-row__meta {
  flex: 1;
  min-width: 0;
}

.edit-row__actions {
  display: flex;
  gap: 4px;
}

.edit-hint {
  margin-top: 16px;
  font-size: 13px;
  color: var(--text-tertiary);
}

/* ── Buttons ── */

.btn {
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  border: none;
  background: var(--accent);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
}

.btn:hover {
  opacity: 0.9;
}

.btn--ghost {
  background: var(--accent-soft);
  color: var(--accent);
}

.btn--icon {
  width: 36px;
  height: 36px;
  padding: 0;
  display: grid;
  place-items: center;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  font-size: 14px;
}

.btn--icon:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.btn--danger {
  background: rgba(255, 59, 48, 0.12);
  color: var(--danger);
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* ── Settings ── */

.settings-group {
  margin-bottom: 28px;
  padding: 16px;
  background: var(--tile-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.settings-group__title {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 14px;
}

.settings-hint {
  font-size: 13px;
  color: var(--text-secondary);
  margin: -8px 0 12px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}

.field--row {
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
}

.field__label {
  font-size: 14px;
  color: var(--text-secondary);
}

.field__control {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg);
}

.check-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.check-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg);
  font-size: 13px;
  cursor: pointer;
}

.check-chip:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

.platform-footer {
  margin-top: 24px;
  text-align: center;
  font-size: 12px;
  color: var(--text-tertiary);
}

.error {
  color: var(--danger);
  padding: 20px;
}

/* ── Command palette ── */

.palette {
  padding: 0;
  border: none;
  background: transparent;
  max-width: none;
  max-height: none;
  width: 100%;
  height: 100%;
}

.palette::backdrop {
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(4px);
}

.palette__panel {
  width: min(92vw, 560px);
  margin: 12vh auto 0;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  max-height: min(70vh, 520px);
}

.palette__input {
  width: 100%;
  padding: 16px 18px;
  border: none;
  border-bottom: 1px solid var(--border);
  background: transparent;
  font-size: 16px;
  outline: none;
}

.palette__results {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 8px;
}

.palette-group-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-tertiary);
  padding: 8px 10px 4px;
}

.palette-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  padding: 10px 12px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  text-align: left;
  cursor: pointer;
  color: inherit;
}

.palette-item:hover,
.palette-item.is-active {
  background: var(--accent-soft);
}

.palette-item__label {
  font-size: 14px;
  font-weight: 500;
}

.palette-item__sub {
  font-size: 12px;
  color: var(--text-tertiary);
}

.palette-empty {
  padding: 20px;
  text-align: center;
  color: var(--text-secondary);
  font-size: 14px;
}

.palette__footer {
  display: flex;
  gap: 16px;
  padding: 10px 14px;
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--text-tertiary);
  flex-shrink: 0;
}

.palette__footer kbd {
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--kbd-bg);
  font-family: inherit;
  margin-right: 4px;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}
