@font-face {
  font-family: 'JetBrains Mono';
  src: url('/fonts/JetBrainsMono-Regular.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'JetBrains Mono';
  src: url('/fonts/JetBrainsMono-Medium.woff2') format('woff2');
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'JetBrains Mono';
  src: url('/fonts/JetBrainsMono-Bold.woff2') format('woff2');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg-primary: #000000;
  --bg-secondary: #1c1c1e;
  --bg-tertiary: #2c2c2e;
  --bg-elevated: #3a3a3c;
  --text-primary: #ffffff;
  --text-secondary: #8e8e93;
  --text-tertiary: #636366;
  --accent: #0a84ff;
  --accent-dark: #0066cc;
  --bubble-mine: #0a84ff;
  --bubble-theirs: #2c2c2e;
  --separator: #38383a;
  --danger: #ff453a;
  --success: #30d158;
  --font: 'JetBrains Mono', monospace;
  --radius: 18px;
  --radius-sm: 10px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  height: 100%;
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.4;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

#app {
  height: 100%;
  width: 100%;
  max-width: 600px;
  margin: 0 auto;
}

.view {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding-top: var(--safe-top);
  padding-bottom: var(--safe-bottom);
}

.hidden {
  display: none !important;
}

/* Header */
.header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--bg-secondary);
  border-bottom: 0.5px solid var(--separator);
  min-height: 52px;
  flex-shrink: 0;
}

.header h1 {
  font-size: 17px;
  font-weight: 700;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-title {
  flex: 1;
  min-width: 0;
}

.header-title h1 {
  font-size: 15px;
}

.subtitle {
  font-size: 11px;
  color: var(--text-secondary);
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.15s;
  white-space: nowrap;
}

.btn:active {
  opacity: 0.7;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-secondary {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.btn-icon {
  width: 18px;
  height: 18px;
  filter: brightness(0) invert(1);
}

.btn-icon-only {
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}

.btn-icon-only:active {
  background: var(--bg-tertiary);
}

.btn-icon-only img {
  width: 22px;
  height: 22px;
  filter: brightness(0) invert(1) sepia(1) saturate(5) hue-rotate(200deg);
}

/* Input */
.input {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-tertiary);
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 14px;
  outline: none;
}

.input::placeholder {
  color: var(--text-tertiary);
}

.input:focus {
  box-shadow: 0 0 0 1px var(--accent);
}

/* Login View */
.login-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
  padding: 32px;
}

.login-logo {
  width: 80px;
  height: 80px;
  filter: brightness(0) invert(1) sepia(1) saturate(5) hue-rotate(200deg);
}

.login-container h1 {
  font-size: 22px;
  font-weight: 700;
  text-align: center;
}

/* Channel List View */
.channel-list {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.channel-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 0.5px solid var(--separator);
  cursor: pointer;
  transition: background 0.15s;
}

.channel-item:active {
  background: var(--bg-secondary);
}

.channel-item-icon {
  width: 40px;
  height: 40px;
  background: var(--bg-tertiary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.channel-item-icon img {
  width: 20px;
  height: 20px;
  filter: brightness(0) invert(1) opacity(0.6);
}

.channel-item-info {
  flex: 1;
  min-width: 0;
}

.channel-item-name {
  font-size: 15px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.channel-item-id {
  font-size: 11px;
  color: var(--text-tertiary);
  font-family: var(--font);
}

.channel-actions {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  border-top: 0.5px solid var(--separator);
  background: var(--bg-secondary);
  flex-shrink: 0;
}

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

.join-row .input {
  flex: 1;
}

.join-row .btn {
  flex-shrink: 0;
}

.channel-empty {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-tertiary);
  font-size: 14px;
  padding: 32px;
  text-align: center;
}

/* Chat View */
.message-list {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.message {
  max-width: 80%;
  padding: 8px 12px;
  border-radius: var(--radius);
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.message-mine {
  align-self: flex-end;
  background: var(--bubble-mine);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.message-theirs {
  align-self: flex-start;
  background: var(--bubble-theirs);
  color: var(--text-primary);
  border-bottom-left-radius: 4px;
}

.message-sender {
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 2px;
}

.message-mine .message-sender {
  display: none;
}

.message-text {
  font-size: 14px;
  line-height: 1.4;
}

.message-time {
  font-size: 10px;
  color: var(--text-secondary);
  margin-top: 2px;
  text-align: right;
}

.message-mine .message-time {
  color: rgba(255, 255, 255, 0.6);
}

.message-date-separator {
  text-align: center;
  color: var(--text-tertiary);
  font-size: 11px;
  padding: 8px 0;
  align-self: center;
}

/* Compose */
.compose {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px 12px;
  background: var(--bg-secondary);
  border-top: 0.5px solid var(--separator);
  flex-shrink: 0;
}

.compose .input {
  flex: 1;
}

.btn-send {
  flex-shrink: 0;
}

.btn-send img {
  width: 24px;
  height: 24px;
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 4px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--bg-elevated);
  border-radius: 2px;
}
